4. Accept inner and outer radius of a ring and print the perimeter and area of the ring (Hint:
perimeter = 2 p (a+b) , area = p (a2-b2) )#include<stdio.h>
#include<conio.h>
void main()
{
int ir,or;
float peri,area;
clrscr();
printf("\nFinding the perimeter and area of ring:");
printf("\nEnter the inner radius of ring:");
scanf("%d",&ir);
printf("\nEnter the outer radius of ring:");
scanf("%d",&or);
peri=2*3.14*(ir*or);
printf("\nPrimeter of ring:%f",peri);
area=3.14*((ir*ir)-(or*or));
printf("\nArea of ring:%f",area);
getch();
}
/*
Finding the perimeter and area of ring:
Enter the inner radius of ring:15
Enter the outer radius of ring:16
Primeter of ring:1507.199951
Area of ring:-97.339996
*/
No comments:
Post a Comment