Logic:
- Enter choice ch
- Enter radius of circle as r
- If ch=1, find area=pi * r * r
- if ch=2 find circumference = 2 * pi * r
- Otherwise print “Wrong Choice”
Algorithm
- Enter choice ch
- Enter radius of circle r
- if (ch == 1)
- {
- a = 3.14 * r * r;
- printf(“the area of circle is %d \n”, a);
- }
- else if (ch == 2)
- {
- c = 2 * 3.14 * r;
- printf(“the circumference of circle is %d”, c);
- }
- else
- printf(“wrong choice”);
Program
#include <stdio.h>
int main()
{
printf("**********************************************************\n");
printf("**********************************************************\n");
printf("** WAP to find area OR circumference of circle **\n");
printf("** Created by Sheetal Garg **\n");
printf("** Assistant Professor **\n");
printf("** Phone No:9467863365 **\n");
printf("**********************************************************\n");
printf("**********************************************************\n");
float r, a, c;
int ch;
printf("enter the radius of circle \n ");
scanf("%f", &r);
printf("enter choice");
scanf("%d", &ch);
if (ch == 1)
{
a = 3.14 * r * r;
printf("the area of circle is %f \n", a);
}
else if (ch == 2)
{
c = 2 * 3.14 * r;
printf("the circumference of circle is %f", c);
}
else
printf("wrong choice");
return 0;
}
Output 1:
********************************************************** ********************************************************** ** WAP to find area OR circumference of circle ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** enter the radius of circle 7 enter choice 1 the area of circle is 153.860001
Output 2:
********************************************************** ********************************************************** ** WAP to find area OR circumference of circle ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** enter the radius of circle 7 enter choice 2 the circumference of circle is 43.959999
Output 3:
********************************************************** ********************************************************** ** WAP to find area OR circumference of circle ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** enter the radius of circle 5 enter choice 3 wrong choice