Add to Favorites    Make Home Page 14955 Online  
 Language Categories  
 Our Services  

Home » C Home » Mathematics Home » Volumes & Areas

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Volumes & Areas
Author P.KalyanSrinivas
Author Email mail_to_kalyan2000 [at] yahoo.com
Description This is a simple program to find the areas and volumes perimeters etc of Geometric shapes.

Category C » Mathematics
Hits 381701
Code Select and Copy the Code
/********************************************************************* ** 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(" "); textcolor(2); cprintf("################################################################# ###############"); textcolor(4); printf(" PROGRAM TO CALCULATE AREAS , VOLUMES , CIRCUMFERENCES "); printf(" ===================================================== "); printf(" OF VARIOUS GEOMETRIC SHAPES"); printf(" =========================== "); 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 "); 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 : " ); 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: "); 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); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi �դ ?�� ��??���
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=677


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review