Friday, August 29, 2014

The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.

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

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;
}

Output

finding area c language

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact