Q.) print area of rectangle in C by getting length and breadth from the user ?
#include<stdio.h>
#include<conio.h>
int main()
{
int length,breadth,area;
printf("Enter the length and breadth of the rectangle :");
scanf("%d%d",&length, &breadth);
area = length * breadth;
printf("area of rectangle is :%d",area);
getch();
}
Output
Enter the length and breadth of the rectangle :7 8 /* say length = 7 and breadth = 8 */.
area of rectangle :56
Q.) print area of circle in C by getting radius from the user ?
#include<stdio.h>
#include<conio.h>
int main()
{
float pi=3.14,radius,area;
printf("Enter the radius of circle :");
scanf("%f",&radius);
area = pi * radius * radius;
printf("area of circle is :%f",area);
getch();
}
Output
Enter the radius of circle :4 /* say radius = 4 */.
area of circle :50.240002