#include <stdio.h>
#include <math.h>
#define PI 3.14
void fnCircle(float, float *, float *);
void fnTriangle(float, float, float, float *, float *);
void fnRectangle(float, float, float *, float *);
void fnSquare(float, float *, float *);
int main(void)
{
char choice;
float area, peri;
do
{
printf("\n\'C\'ircle\n\'T\'riangle\n\'R\'ectangle\n\'S\'quare\n\'E\'xit\nChoice :");
fflush(stdin);
scanf("%c", &choice);
switch(choice)
{
case 'c':
case 'C':
{
float radius;
printf("Enter the radius :");
scanf("%f", &radius);
fnCircle(radius, &area, &peri);
printf("\nArea of circle is %f", area);
printf("\nPerimeter of circle is %f", peri);
break;
}
case 't':
case 'T':
{
float s1, s2, s3;
printf("Enter the three sides :");
scanf("%f%f%f", &s1, &s2, &s3);
fnTriangle(s1, s2, s3, &area, &peri);
printf("\nArea of triangle is %f", area);
printf("\nPerimeter of triangle is %f", peri);
break;
}
case 'r':
case 'R':
{
float length, breadth;
printf("Enter the length and breadth :");
scanf("%f%f", &length, &breadth);
fnRectangle(length, breadth, &area, &peri);
printf("\nArea of rectangle is %f", area);
printf("\nPerimeter of rectangle is %f", peri);
break;
}
case 's':
case 'S':
{
float side;
printf("Enter the side :");
scanf("%f", &side);
fnSquare(side, &area, &peri);
printf("\nArea of square is %f", area);
printf("\nPerimeter of square is %f", peri);
break;
}
default :
printf("\nInvalid choice");
}
}while(choice != 'E' && choice != 'e');
return 0;
}
void fnCircle(float r, float *a, float *p)
{
*a = PI * r * r;
*p = 2 * PI * r;
}
void fnTriangle(float s1, float s2, float s3, float *a, float *p)
{
float semi_peri;
*p = s1 + s2 + s3;
semi_peri = 0.5 * (*p);
*a = sqrt(semi_peri * (semi_peri - s1) * (semi_peri - s2) * (semi_peri - s3));
}
void fnRectangle(float l, float b, float *a, float *p)
{
*a = l * b;
*p = 2 * (l + b);
}
void fnSquare(float s, float *a, float *p)
{
*a = s * s;
*p = 4 * s;
}
#include <math.h>
#define PI 3.14
void fnCircle(float, float *, float *);
void fnTriangle(float, float, float, float *, float *);
void fnRectangle(float, float, float *, float *);
void fnSquare(float, float *, float *);
int main(void)
{
char choice;
float area, peri;
do
{
printf("\n\'C\'ircle\n\'T\'riangle\n\'R\'ectangle\n\'S\'quare\n\'E\'xit\nChoice :");
fflush(stdin);
scanf("%c", &choice);
switch(choice)
{
case 'c':
case 'C':
{
float radius;
printf("Enter the radius :");
scanf("%f", &radius);
fnCircle(radius, &area, &peri);
printf("\nArea of circle is %f", area);
printf("\nPerimeter of circle is %f", peri);
break;
}
case 't':
case 'T':
{
float s1, s2, s3;
printf("Enter the three sides :");
scanf("%f%f%f", &s1, &s2, &s3);
fnTriangle(s1, s2, s3, &area, &peri);
printf("\nArea of triangle is %f", area);
printf("\nPerimeter of triangle is %f", peri);
break;
}
case 'r':
case 'R':
{
float length, breadth;
printf("Enter the length and breadth :");
scanf("%f%f", &length, &breadth);
fnRectangle(length, breadth, &area, &peri);
printf("\nArea of rectangle is %f", area);
printf("\nPerimeter of rectangle is %f", peri);
break;
}
case 's':
case 'S':
{
float side;
printf("Enter the side :");
scanf("%f", &side);
fnSquare(side, &area, &peri);
printf("\nArea of square is %f", area);
printf("\nPerimeter of square is %f", peri);
break;
}
default :
printf("\nInvalid choice");
}
}while(choice != 'E' && choice != 'e');
return 0;
}
void fnCircle(float r, float *a, float *p)
{
*a = PI * r * r;
*p = 2 * PI * r;
}
void fnTriangle(float s1, float s2, float s3, float *a, float *p)
{
float semi_peri;
*p = s1 + s2 + s3;
semi_peri = 0.5 * (*p);
*a = sqrt(semi_peri * (semi_peri - s1) * (semi_peri - s2) * (semi_peri - s3));
}
void fnRectangle(float l, float b, float *a, float *p)
{
*a = l * b;
*p = 2 * (l + b);
}
void fnSquare(float s, float *a, float *p)
{
*a = s * s;
*p = 4 * s;
}
No comments:
Post a Comment
kiss on google ads if you are anonymous because your ip is trackable.thank you.
......from.admin