Okay, so I've made two programs in C so far... I skipped the hello world thing as usual for me, but anyway, this is my second program... It opens up in the command prompt. Well, anyway here it is! The source is here:
Code:
#include <stdio.h>
main()
{
int Loop=0;
int Type=0;
float AddToNum=0;
float AddNum=0;
float AddResult=0;
float SubtractFromNum=0;
float SubtractNum=0;
float SubtractResult=0;
float MultiplyByNum=0;
float MultiplyNum=0;
float MultiplyResult=0;
float DivideByNum=0;
float DivideNum=0;
float DivideResult=0;
printf("\nSimple Calculator, by Zamurick\n");
while ( Loop < 1 ) {
printf("\nHere are your options: \n");
printf("1 Add\n2 Subtract\n3 Multiply\n");
printf("4 Divide\n5 Exit");
printf("\nType Your Choice (1-5): ");
scanf("%d", &Type);
if (Type==1) {
printf("\nEnter the number you would like to add to: ");
scanf("%f", &AddToNum);
printf("\nEnter the number you want to add: ");
scanf("%f", &AddNum);
AddResult = AddToNum + AddNum;
printf("\nThe sum of those numbers is %.8f.\n", AddResult);
}
else if (Type==2) {
printf("\nEnter the number you would like to subtract from: ");
scanf("%f", &SubtractFromNum);
printf("\nEnter the number you want to subtract: ");
scanf("%f", &SubtractNum);
SubtractResult = SubtractFromNum + SubtractNum;
printf("\nThe difference of those numbers is %.8f.\n", SubtractResult);
}
else if (Type==3) {
printf("\nEnter the number you would like multiply: ");
scanf("%f", &MultiplyByNum);
printf("\nEnter the other number you want to multiply: ");
scanf("%f", &MultiplyNum);
MultiplyResult = MultiplyByNum * MultiplyNum;
printf("\nThe result of multiplying those numbers is %.8f.\n", MultiplyResult);
}
else if (Type==4) {
printf("\nEnter the number you would like to divide: ");
scanf("%f", &DivideNum);
printf("\nEnter the number you want to divide by: ");
scanf("%f", &DivideByNum);
DivideResult = DivideNum / DivideByNum;
printf("\nThe result of dividing those numbers is %.8f.\n", DivideResult);
}
if (Type==5) {
Loop++;
printf("Goodbye.");
}
}
}

