You are on page 1of 8

Roll No: B21600 Page no: 1

BASIC PROGRAMMING
CONSTRUCTURE
Exp no: 02 Date:26|10|2021
Aim: programs using the concept of variable, operators and datatypes

Theory:

Flowchart 2.1:
C program 2.1

#include<stdio.h>
int main()
{
int l, b, a, peri=0;
float radius, areac=0.0, circ=0.0;

//input
printf("enter the value of length and breath of the rectangle\n");
scanf("%d %d",&l, &b);
printf("\nEnter the value of radius of circle\n");
scanf("%f", &radius);

//process
a=l*b;
peri=2*(l*b);
areac=3.14*radius*radius;
circ=2*3.14*radius;

//output
printf("\nArea of the rectangle =%d\n\n", a);
printf("perimeter of the rectangle =%d\n\n", peri);
printf("Area of a circle =%f\n\n", areac);
printf("circumference of circle =%f\n\n", circ);
return 0;
}
Flowchart 2.2
C program 2.2 :

#include<stdio.h>

int main()

float fah, cel;

printf("Program to convert fahrenheit to celsius\n");

printf("Enter the Fahrenheit\n");

scanf("%f",&fah);

cel=(fah-32)*5/9;

printf("The celcius is %f",cel);

return 0;

}
Flowchart 2.3
C program 2.3 :

#include<stdio.h>

int main()

int n;

float p, r, si;

printf("programe to find the simple interest\n");

printf("enter the number of years\n");

//n stand for number of years

scanf("%d",&n);

printf("Enetr the principal amount\n");

//p stand for principal amount

scanf("%f",&p);

printf("Enter the interest rate \n");

//r stand for interest rate

scanf("%f",&r);

si=n*p*r/100;

printf("the simple interest is %f",si);

return 0;

}
flowchart 2.4:
C Program 2.4:

#include<stdio.h>

int main()

float r=0.0, pi=3.14;

printf("programe to find the volume of sphere\n");

printf("Enter the radius");

scanf("%f",&r);

float vol=pi*r*r*r*4/3;

printf("the volume of sphere %f",vol);

return 0;

You might also like