Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
2.docx
1. 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:
2. 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("enterthe value of length and breath of the rectanglen");
scanf("%d %d",&l,&b);
printf("nEnterthe value of radius of circlen");
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 =%dnn",a);
printf("perimeter of the rectangle =%dnn",peri);
printf("Area of a circle =%fnn", areac);
printf("circumferenceof circle =%fnn", circ);
return 0;
}
4. C program 2.2 :
#include<stdio.h>
int main()
{
float fah, cel;
printf("Program to convertfahrenheitto celsiusn");
printf("Enter the Fahrenheitn");
scanf("%f",&fah);
cel=(fah-32)*5/9;
printf("Thecelcius is %f",cel);
return 0;
}
6. C program 2.3 :
#include<stdio.h>
int main()
{
int n;
float p, r, si;
printf("programeto find the simple interestn");
printf("enter the number ofyearsn");
//n stand for number of years
scanf("%d",&n);
printf("Enetr the principalamountn");
//p stand for principalamount
scanf("%f",&p);
printf("Enter the interestrate n");
//r stand for interestrate
scanf("%f",&r);
si=n*p*r/100;
printf("the simple interestis %f",si);
return 0;
}
8. C Program 2.4:
#include<stdio.h>
int main()
{
float r=0.0,pi=3.14;
printf("programeto find the volume of spheren");
printf("Enter the radius");
scanf("%f",&r);
float vol=pi*r*r*r*4/3;
printf("the volume of sphere %f",vol);
return 0;
}