123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
--------------------------------------------------------------------------------

Volumes & Areas

--------------------------------------------------------------------------------

Description : This is a simple program to find the areas and volumes perimeters etc of Geometric shapes.

/*********************************************************************
** PROGRAM TO CALCULATE AREA,VOLUME,PERIMETER OF A PARTICULAR
**
** GEOMETRIC SHAPE **

*********************************************************************/

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI 3.14159
char ch;
main()
{

clrscr();

textcolor(4);
intro();
getch();
textcolor(7);
clrscr();
do
{
ch=menu();
switch(ch)
{
case 'a':
case 'A':
clrscr();
square();
getch();
break;
case 'b':
case 'B':
clrscr();
rect();
getch();
break;
case 'c':
case 'C':
clrscr();
circl();
getch();
break;
case 'd':
case 'D':
clrscr();
tri();
getch();
break;
case 'e':
case 'E':
clrscr();
rom();
getch();
break;
case 'f':
case 'F':
clrscr();
para();
getch();
break;

case 'g':
case 'G':
clrscr();
tra();
getch();
break;
case 'h':
case 'H':
clrscr();
qua();
getch();
break;
case 'i':
case 'I':
clrscr();
semicir();
getch();
break;
case 'j':
case 'J':
clrscr();
msector();
getch();
break;

case 'k':
case 'K':
clrscr();
sphere();
getch();
break;
case 'l':
case 'L':
clrscr();
cone();
getch();
break;
case 'm':
case 'M':
clrscr();
cyll();
getch();
break;

case 'n':
case 'N':
clrscr();
cube();
getch();
break;
case 'o':
case 'O':
clrscr();
cuboid();
getch();
break;
case 'p':
case 'P':
clrscr();
hemisphe();
getch();
break;

case 'q':
case 'Q':
exit(1);
}
} while(ch!='Q'||ch!='q');
getch();
}
intro()
{
int i;
clrscr();
printf("


<BR>);
textcolor(2);


cprintf("#################################################################
###############");
textcolor(4);
printf("



PROGRAM TO CALCULATE AREAS , VOLUMES ,
CIRCUMFERENCES ");
printf("

=====================================================<BR>);
printf("
OF VARIOUS GEOMETRIC SHAPES");
printf("
===========================
<BR>);
textcolor(2);

cprintf("#################################################################
###############");
getch();

printf("





Program developed and designed
by...

");
printf("KALYAN SRINIVAS . PABOLU ");

}
menu()
{
clrscr();
textcolor(7);
printf(" MENU
Two Dimensional Shapes.

-----------------------

A.SQUARE
B.RECTANGLE

C.CIRCLE
D.TRIANGLE

E.RHOMBUS
F.PARALLELOGRAM

G.TRAPEZIUM
H.QUADRILATERAL.

I.SEMICERCLE
J.SECTOR<BR>);
printf("
Three Dimensional Shapes.

-------------------------

K.SPHERE
L.CONE
M.CYLLINDER

N.CUBE
O.CUBOID
P.HEMISPHERE

Q.QUIT
Enter Your Choice :");
scanf("%c",&ch);
return(ch);
}

/***** SUB FUNCTIONS *****/
/***** 2 D SHAPES *****/

square()
{
float s,a,p;int i,j;
printf("
Enter side of square:");
scanf("%f",&s);
a=s*s;
p=4*s;
printf("
Perimeter of square : %.3f units",p);
printf("
Area of square : %.3f sq.units",a);
printf("
Square is ...
");
for(i=1;i<=s;i++)
{
textcolor(10);
for(j=1;j<=s;j++)
cprintf("ÛÛ");
printf("
");
}
return(0);
}
rect()
{
float a,p,l,b; int i,j;
printf("
Enter length and breadth of rectangle:
Length:");
scanf("%f",&l);
printf("
Breadth:");
scanf("%f",&b);
a=l*b;
p=2*(l+b);
printf("
Perimeter of rectangle : %.3f units",p);
printf("
Area of rectangle : %.3f sq.units",a);
printf("
Rectangle is...
");
for(i=1;i<=b;i++)
{
textcolor(4);
for(j=1;j<=l;j++)
cprintf("ÛÛ");
printf("
");
}
return(0);
}
tri()
{
float area,p;
float a,b,c,s;
printf("
Enter three sides of triangle:");
scanf( "%f%f%f",&a,&b,&c);
p=a+b+c;
s=p/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("
Perimeter of triangle : %.3f units",p);
printf("
Area of a triangle : %.3f sq.units",area);
}
rom()
{
float s,d1,d2,a,p;
printf("
Enter side and diagonals of a rhombus:
Side:");
scanf("%f",&s);
printf("
Diagonal :");scanf("%f",&d1);
printf("
Diagonal :");scanf("%f",&d2);
a=0.5*d1*d2;
p=4*s;
printf("
Perimeter of rhombus :%.3f units",p);
printf("
Area of rhombus :%.3f sq.units",a);
}
circl()
{
float r,a,p;
printf("Enter radius of circle:");
scanf("%f",&r);
a=PI * r * r;
p=2 * PI * r;
printf("
Circumference of circle : %.3f units",p);
printf("
Area of circle : %.3f sq.units",a);
}
para()
{
float a,p,base,h,l,b;
printf("Enter height,length,breadth of parallalogram :<BR> );
printf("
Height :"); scanf("%f",&h);
printf("
Base or Length :"); scanf("%f",&l);
printf("
Breadth :"); scanf("%f",&b);
base=l;
a=base*h;
p=2 * ( l + b );
printf("
Perimeter of parallalogram :%.3f units",p);
printf("
Area of parallogram :%.3f sq.units",a);

}


tra()
{
float a,b,d,are;
printf("Enter height and lengths of two parallel sides:
Height :");
scanf("%f",&d);
printf("Side:"); scanf("%f",&a);
printf("Side:"); scanf("%f",&b);
are=0.5 * d * (a+b);
printf("
Area of trapezium : %.3f sq.units",are);
}
qua()
{
float a,b,area,d;
printf("Enter diagonal and perpendicular distances from opposite
vertices:<BR>);
printf("Diagonal :"); scanf("%f",&d);
printf("
Distance :"); scanf("%f",&a);
printf("
Distance :");scanf("%f",&b);
area= 0.5 * d * (a + b);
printf("
Area of quadrilateral : %.3f sq.units", area);
}
semicir()
{
float a,p,r;
printf("Enter radius of semicircle:");
scanf("%f",&r);
a=0.5* PI * r * r;
p= (PI * r ) + (2 * r);
printf("
Circumference of semicircle : %.3f units",p);
printf("
Area of semicircle : %.3f sq.units",a);
}

msector()
{
float x,r,temp,a,p;
printf("Enter radius and angle of sector:");
printf("
Radius :");
scanf("%f",&r);
printf("
Angle(in degrees) :");
scanf("%f",&x);
temp= x/360;
a= temp * (PI * r * r);
p= temp * (2 * PI * r);
printf("
Circumference of sector : %.3f units",p);
printf("
Area of sector : %.3f sq.units",a);
}

/******** 3 DIMENSIONAL SHAPES *********/

sphere()
{
float lsa,tsa,v,r;
printf("Enter radius of sphere :");
scanf("%f",&r);
tsa=4*PI*r*r;
v=(4.0/3.0)*PI*r*r*r;
printf("
Total surface area of sphere :%.3f sq.units",tsa);
printf("
Volume of sphere :%.3f cu.units",v);
}
cone()
{
float h,r,s ,v,tsa,lsa;
printf("Enter base radius ,height, slant height of cone :");
printf("
Radius :"); scanf("%f",&r);
printf("
Height :"); scanf("%f",&h);
printf("
Slant height :"); scanf("%f",&s);
tsa=PI * r *(s+r);
lsa=PI * r * s;
v=(PI * r * r * h)/3;
printf("
Total surface area of cone :%.3f sq.units",tsa);
printf("
Lateral surface area of cone :%.3f sq.units",lsa);
printf("
Volume of cone :%.3f cu.units",v);
}
cyll()
{
float lsa,tsa,v,r,h;
printf("Enter height and radius of cyllinder");
printf("Height :"); scanf("%f",&h);
printf("Radius :"); scanf("%f",&r);
lsa=2*PI*r*h;
tsa=2*PI*r*(h+r);
v=PI*r*r*h;
printf("
Total surface area of cyllinder :%.3f sq.units",tsa);
printf("
Curved surface area of cyllinder :%.3f sq.units",lsa);
printf("
Volume of cyllinder :%.3f cu.units",v);
}
cube()
{
float lsa,tsa,v,s,d;
printf("Enter side of cube :");
scanf("%f",&s);
d=s*sqrt(3);
lsa=4 * s * s;
tsa=6 * s * s;
v= s * s * s;
printf("
Diagonal of cube :%.3f units",d);
printf("
Total surface area of cube :%.3f sq.units",tsa);
printf("
Lateral surface area of cube :%.3f sq.units",lsa);
printf("
Volume of cube :%.3f cu.units",v);
}
cuboid()
{
float lsa,tsa,v,l,b,d,h;
printf("Enter length,breadth,height of cuboid :");
printf("
Length :"); scanf("%f",&l);
printf("
Breadth :"); scanf("%f",&b);
printf("
Height :"); scanf("%f",&h);
d=sqrt(l*l + b*b + h*h );
lsa =2 * h *( l+b );
tsa = lsa + 2 * l * b;
v=l*b*h;
printf("
Diagonal of cuboid :%.3f units",d);
printf("
Total surface area of cuboid :%.3f sq.units",tsa);
printf("
Lateral surface area of cuboid :%.3f sq.units",lsa);
printf("
Volume of cuboid :%.3f cu.units",v);
}
hemisphe()
{
float lsa,tsa,v,r;
printf("Enter radius of hemisphere :");
scanf("%f",&r);
tsa=3*PI*r*r;
lsa=2*PI*r*r;
v=(2.0/3.0)*PI*r*r*r;
printf("
Total surface area of hemisphere :%.3f sq.units",tsa);
printf("
Lateral surface area of hemisphere :%.3f sq.units",lsa);
printf("
Volume of hemisphere :%.3f cu.units",v);
}

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG