Site hosted by Angelfire.com: Build your free website today!

Here I have a program that will find the area of a circle, a square, a trapezoid and a triangle. This program was probably one of the easiest to make. All you have to do with this program is to enter in a few or one input and an answer is then given to you.



Want to Download the Program?


This is the Code for The Program.


#include <stdio.h> #include "iostream.h" double tri(double base, double height); double square(double width, double height); double circle(double radius); double trap(double base, double base2, double height); int main(void) { double base,height,ans,width,radius,base2; int shape; do{ cout<<"\t\t What would you like to find? (Enter a #) \n\n"; cout<<"\t\t\t********************************\n"; cout<<"\t\t\t*\t (1). Triangle *\n"; cout<<"\t\t\t*\t (2). Square *\n"; cout<<"\t\t\t*\t (3). Circle *\n"; cout<<"\t\t\t*\t (4). Trapezoid *\n"; cout<<"\t\t\t********************************\n\n\t\t\t\t\t"; cin>>shape; cout<<"\n\n"; switch(shape) { case 1: cout<<"What is the base length? "; cin>>base; cout<<"What is the Height of the Triangle? "; cin>>height; cout<<"\nArea of The Triangle is "<<tri(base,height)<<"\n\n\n\n"; break; case 2: cout<<"What is the Width? "; cin>>width; cout<<"What is the Height? "; cin>>height; cout<<"\nArea of The Square is "<<square(width,height)<<"\n\n\n\n"; break; case 3: cout<<"What is the radius? "; cin>>radius; cout<<"Area of The Cirlce is "<<circle(radius)<<"\n\n\n\n"; break; case 4: cout<<"What is one of the base length? "; cin>>base; cout<<"What is the other base length? "; cin>>base2; cout<<"What is the Height? "; cin>>height; cout<<"Area of The Trapezoid is "<<trap(base,base2,height)<<"\n\n\n\n"; break; case 5: default: break; } }while(100); return 0; } double tri(double base, double height) { return (0.5*base*height); } double square(double width, double height) { return (width*height); } double circle(double radius) { double pi=3.1415926; return (pi*(radius*radius)); } double trap(double base, double base2, double height) { return (((base+base2)/2)*height); }