I just started doing the C tutorials yesterday and decided to apply the little i have learnt. My calculator is supposed to take an input for two numbers, then it has to print a menu whit four mathematical operations and takes input of the operation selected. If conditions apply to each operation. After that has been done the result of the operation is supposed to be printed. The code complies with no errors but after the second number has been inputed it prints the menu and the result. Here is my code and any sort of help will be greatly appreciated. Thank You
Code:#include <stdio.h> int main() { /*Author: Morpheous 11 14th December 2008 */ double firstNum; double secNum; double result; char operationSelected; printf("Enter your first number:\n"); scanf("%lf",&firstNum); printf("Enter your second number:\n"); scanf("%lf",&secNum); printf("Please select an operation\n"); printf("addition(+)\n"); printf("subtraction(-)\n"); printf("multiplication(*)\n"); printf("division(/)\n"); scanf("%c",&operationSelected); if (operationSelected == '+') { result = firstNum + secNum; }// end of if statement for addition else if (operationSelected == '-') { result = secNum - firstNum; }// end of if statement for subtraction else if (operationSelected == '*') { result = firstNum * secNum; }// end of if statement for multiplication else if (operationSelected == '/') { result = firstNum / secNum; }// end of if statement for division else printf("Enter a valid operation"); printf("The result is %lf",result); getchar(); return 0; }// end of main