Hint:
Area of rectangle = length * breadth
Perimeter of a rectangle is the sum of the lengths of all the sides of the rectangle
Area of a circle = 3.1415 * (radius)2 hint: (radius)2 = radius * radius
Circumference of a circle = 3.1415 * diameter of a circle
int main()
{
int a,b,area_r,area_c,peri_r,peri_c,r;
printf ("Enter length and width of rectangle: ");
scanf ("%d%d",&a,&b);
printf ("Enter radius: ");
scanf ("%d",&r);
area_r = (a * b);
peri_r = ((2*a) + (2*b));
area_c = (3.14 * r * r);
peri_c = (3.14 * 2 * r);
printf ("\n\nArea of rectangle = %d",area_r);
printf ("\nPerimeter of rectabgle = %d",peri_r);
printf ("\n\nArea of the circle = %d",area_c);
printf ("\nCircumference of the circle = %d",peri_c);
printf ("\n\nPress any key to close.");
getch ();
return 0;
}
Area of rectangle = length * breadth
Perimeter of a rectangle is the sum of the lengths of all the sides of the rectangle
Area of a circle = 3.1415 * (radius)2 hint: (radius)2 = radius * radius
Circumference of a circle = 3.1415 * diameter of a circle
Code
#include<stdio.h>int main()
{
int a,b,area_r,area_c,peri_r,peri_c,r;
printf ("Enter length and width of rectangle: ");
scanf ("%d%d",&a,&b);
printf ("Enter radius: ");
scanf ("%d",&r);
area_r = (a * b);
peri_r = ((2*a) + (2*b));
area_c = (3.14 * r * r);
peri_c = (3.14 * 2 * r);
printf ("\n\nArea of rectangle = %d",area_r);
printf ("\nPerimeter of rectabgle = %d",peri_r);
printf ("\n\nArea of the circle = %d",area_c);
printf ("\nCircumference of the circle = %d",peri_c);
printf ("\n\nPress any key to close.");
getch ();
return 0;
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.