#include <stdio.h> //This is include information about standard library
#include <math.h> //math function includes about math commands
main() //User define function
{
//circle
float pi=3.14,r,a,b,c; //Float funcion which takes all float values
printf("Enter the value for r: "); //which asks the user input
scanf("%f",&r); //which attach the user input to r variable
a=pow(r,2); //a variable equals to r sqare using pow function
b=pi*a; //formula for circle area
c=2*pi*r; //formula for circle perimeter
printf("Circle area :%f\n",b); //printing circle area
printf("perimeter :%f\n",c); //printing circle perimeter
//square
float d,e,f; //Float funcion which takes all float values
printf("Enter the value for a: "); //which asks the user input
scanf("%f",&d); //which attach the user input to a variable
e=pow(d,2); //formula for area of square
f=4*d; //formula for perimeter of square
printf("Square area :%f\n",e); //prints area of square
printf("Square perimeter :%f\n",f); //prints perimeter of square
//triangle
float g,h,i,j,k,l; //Float funcion which takes all float values
printf("Enter the value for side a: "); //user input for side a
scanf("%f",&g); //which attaches the user input to a variable a
printf("Enter the value for side b: "); //user input for side b
scanf("%f",&h); //which attaches the user input to a variable b
printf("Enter the value for side c: "); //user input for side c
scanf("%f",&i); //which attaches the user input to a variable c
l=(g+h+i)/2;
j=sqrt(l*(l-g)*(l-h)*(l-i)); //formula for triangle area
printf("Triangle area :%f\n",j); //printing the triangle area
k=g+h+i; //formula for triangle perimeter
printf("Triangle perimeter :%f\n",k); //printing the triangle perimeter
//rectangle
float m,n,o,p; //Float funcion which takes all float values
printf("Enter the value for length l: "); //which takes the valuse for length from user input
scanf("%f",&m); //which attaches the user input to variable l
printf("Enter the value for bredth b: "); //which takes the valuse for bredths from user input
scanf("%f",&n); //which attaches the user input to variable b
o=m*n; //formula for rectangle area
p=2*(m+n); //formula for rectangle perimeter
printf("Rectangle area :%f\n",o); //prints rectangle area
printf("perimeter :%f\n",p); //prints rectangle perimeter
//ellipse
float u=3.14,q,v,s,t; //Float funcion which takes all float values
printf("Enter the value for major axis a: "); //which takes value for the major axis from the userinput
scanf("%f",&q); //which attach the user input to a variable a
printf("Enter the value for minor axis b: "); //which asks the user input for the minor axis
scanf("%f",&v); //which attach the user input to a variable b
s=u*q*v; //formula for Ellipse area
t=2*u*sqrt((pow(q,2)+pow(v,2))/2); //formula for Ellipse perimeter
printf("Ellipse area :%f\n",s); //printing Ellipse area
printf("Ellipse perimeter :%f\n",t); //printing Ellipse perimeter
}
#include <math.h> //math function includes about math commands
main() //User define function
{
//circle
float pi=3.14,r,a,b,c; //Float funcion which takes all float values
printf("Enter the value for r: "); //which asks the user input
scanf("%f",&r); //which attach the user input to r variable
a=pow(r,2); //a variable equals to r sqare using pow function
b=pi*a; //formula for circle area
c=2*pi*r; //formula for circle perimeter
printf("Circle area :%f\n",b); //printing circle area
printf("perimeter :%f\n",c); //printing circle perimeter
//square
float d,e,f; //Float funcion which takes all float values
printf("Enter the value for a: "); //which asks the user input
scanf("%f",&d); //which attach the user input to a variable
e=pow(d,2); //formula for area of square
f=4*d; //formula for perimeter of square
printf("Square area :%f\n",e); //prints area of square
printf("Square perimeter :%f\n",f); //prints perimeter of square
//triangle
float g,h,i,j,k,l; //Float funcion which takes all float values
printf("Enter the value for side a: "); //user input for side a
scanf("%f",&g); //which attaches the user input to a variable a
printf("Enter the value for side b: "); //user input for side b
scanf("%f",&h); //which attaches the user input to a variable b
printf("Enter the value for side c: "); //user input for side c
scanf("%f",&i); //which attaches the user input to a variable c
l=(g+h+i)/2;
j=sqrt(l*(l-g)*(l-h)*(l-i)); //formula for triangle area
printf("Triangle area :%f\n",j); //printing the triangle area
k=g+h+i; //formula for triangle perimeter
printf("Triangle perimeter :%f\n",k); //printing the triangle perimeter
//rectangle
float m,n,o,p; //Float funcion which takes all float values
printf("Enter the value for length l: "); //which takes the valuse for length from user input
scanf("%f",&m); //which attaches the user input to variable l
printf("Enter the value for bredth b: "); //which takes the valuse for bredths from user input
scanf("%f",&n); //which attaches the user input to variable b
o=m*n; //formula for rectangle area
p=2*(m+n); //formula for rectangle perimeter
printf("Rectangle area :%f\n",o); //prints rectangle area
printf("perimeter :%f\n",p); //prints rectangle perimeter
//ellipse
float u=3.14,q,v,s,t; //Float funcion which takes all float values
printf("Enter the value for major axis a: "); //which takes value for the major axis from the userinput
scanf("%f",&q); //which attach the user input to a variable a
printf("Enter the value for minor axis b: "); //which asks the user input for the minor axis
scanf("%f",&v); //which attach the user input to a variable b
s=u*q*v; //formula for Ellipse area
t=2*u*sqrt((pow(q,2)+pow(v,2))/2); //formula for Ellipse perimeter
printf("Ellipse area :%f\n",s); //printing Ellipse area
printf("Ellipse perimeter :%f\n",t); //printing Ellipse perimeter
}
No comments:
Post a Comment