Week 4

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

COMPUTER PROGRAMMING

Engr. Anees Ahmed Soomro


Assistant Professor
CSE QUEST Nawabshah
INTRODUCTION TO COMPUTER PROGRAMMING

1) Scanf function with variables


2) Working with scanf function and variables
2) Decisions in C, such as simple if
3) if-else, else if and Manual expression to Computer Expressions
scanf function
scanf function is used to take input from user.

Syntax:
scanf(“%d”,&variable);
scanf function to take number from user and display the entered
number

#include<stdio.h>
void main(void)
{
int number;
printf(“Enter number”);
scanf(“%d”,&number);
printf(“Entered number is %d”,number);

}
Working with scanf function

a. Write a program in C to take three numbers and display its addition.


b. Write a program in C to take two numbers and display its multiplication.
c. Write a program in C to take two numbers and display its division.
d. Write a program in C to take two numbers and display its subtraction.
e. Write a program in C to take subject marks and find its percentage.
f. Write a program in C to take radius and pi for area of circle.
g. Write a program in C to take side of Square and find its Area.
h. Write a program in C to take length and width of rectangle and find its
Area
Decisions in C
C language needs decisions be taken for desired results which are
below

• simple if
• if-else
• else if
• switch
Simple if
Syntax

if(condition)
statement

if-else
Syntax

if(condition)
Statement
else
statement
else if
Syntax

if(condition)
statement
else if(condition)
statement
else if(condition)
statement
else if(condition)
Statement
else
Statement
Manual expression to computer based expressions

You might also like