Monday, 19 September 2011

control statements in C

Program to input the radius of a circle and if radius is greater than 10 then calculate area, circumference,diameter otherwise calculate only are.
#include<stdio.h>
#include<conio.h>
void main()
{
float r,a,c,d;
clrsc();
printf("Enter the radius of the circle: ");
scanf("%f",&r);
if(r>10)
{
d=2*r;
c=2*3.14*r;
a=3.14*r*r;
printf("\nThe diameter of the circle is: %f",d);
}
else
{
a=3.14*r*r;
c=2*3.14*r;
}
printf("\nThe area of the circle is: %f",a);
printf(\nThe circumference is: %f",c);
getch();
}

No comments:

Post a Comment