forked from MIETDevelopers/2020a1r027_toyaib_CSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userswitch.c
28 lines (27 loc) · 996 Bytes
/
userswitch.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//program to calculate area of circle, square and rectangle based on user choice.
#include <stdio.h>//header file
#include <math.h>//header file to include mathematical functions
int main()//main function
{
char purpose;
printf("Enter the mode of operation.\n 1.Area of Circle.\n 2.Area of Square.\n 3.Area of Rectangle.\n");
scanf("%c", &purpose); //scanning the operater entered by user.
float value1, value2;
printf("Enter values of the shape:\n");
scanf("%f %f", &value1, &value2); //scanning the numbers entered by user.
switch(purpose) //Switch-Case Function used.
{
case'1':
printf("Area of Circle = %f", ((22*value1*value1)/7));//printing area of circle
break;
case'2':
printf("Area of Square = %f", value1*value1);//printing area of square
break;
case'3':
printf("Area of Rectangle = %f", value1*value2);//printing area of rectangle
break;
default:
printf("Error eccoured, Please enter the values correctly!"); //default
}
return 0;
}