Hey all, I have little programming experience...I have pretty much been just making this one program and expanding upon it when I find some new stuff that can be added. It is a small calculator I am pretty proud of it considering how small it was when it started out (It's still small I know) I was just wondering if you all could take a look at it and tell me if there is any thing that I can improve upon. I know I should not use system pause or system CLS lol I should realy stop doing that still trying to figure out the "right" way to clear screen and what not . Any constructive critique is greatly appreciated. Thanks in advance.
Code:
#include <stdio.h>
#include <stdlib.h>
#define PI 3.14156
int main(int argc, char *argv[])
{
int num1,num2,pi,plus,sub,le,ba,ra,ar,he,menu,a,mul;
float di, ci;
printf("-----------------------------------------\n"
"Welcome to my simple Calculation Program!\n"
"-----------------------------------------\n"
"(c) copyright 2005 James L. Curtis\n"
"-----------------------------------------\n");
system("PAUSE");
system("CLS");
printf(" Main Menu \n");
printf("-> 1 - Addition\n");
printf("-> 2 - Subtraction\n");
printf("-> 3 - Multiplication\n");
printf("-> 4 - Area Calculation\n");
printf("-> ");
scanf("%d", &menu);
system("CLS");
switch (menu) {
case 1:
printf("Please enter a number ");
scanf("%d",&num1);
printf("Please enter another number ");
scanf("%d",&num2);
plus = (num1+num2);
printf("Your answer is %d\n\n",plus);
break;
case 2:
printf("Please enter a number ");
scanf("%d",&num1);
printf("Enter the ammount you wish to subtract from the first number ");
scanf("%d",&num2);
sub = (num1-num2);
printf("Your answer is %d\n\n",sub);
break;
case 3:
printf("Please enter a number ");
scanf("%d",&num1);
printf("Enter the ammount you wish to multiply the first by ");
scanf("%d",&num2);
mul = (num1*num2);
printf("Your answer is %d\n\n",mul);
break;
case 4:
printf(" Select the shape you wish to calculate the area of\n");
printf("-> 1 - Square\n");
printf("-> 2 - Rectangle\n");
printf("-> 3 - Triangle\n");
printf("-> 4 - Circle\n");
printf("-> ");
scanf("%d", &a);
if(a == 1){
printf("Please enter the length of one side of the square: ");
scanf("%d",&le);
printf("\n");
ar = (le*le);
printf("The area of the square is %d",ar);
printf("\n\n");
}
else if(a == 2){
printf("Please enter the length of the rectangle: ");
scanf("%d",&le);
printf("Please enter the heigth of the rectangle: ");
scanf("%d",&he);
ar = (le*he);
printf("The area of the square is %d",ar);
printf("\n\n");
}
else if(a == 3){
printf("Please enter The base of the triangle: ");
scanf("%d",&ba);
printf("Please enter The height of the triangle: ");
scanf("%d",&he);
ar = (ba/2*he);
printf("The area of the triangle is %d",ar);
printf("\n\n");
}
else if(a == 4){
printf("Please enter the diameter of the circle: ");
scanf("%f",&di);
ci = (PI*di);
printf("The circumferance of the circle is %f",ci);
printf("\n\n");
}
break;
}
printf("Thank you for using Curtis Calculator v1.2\n\nTo report any errors or to send ideas for future versions\n"
"Please E-mail me at [email protected] \n\n");
system("PAUSE");
return 0;
}