hello i am trying to write a simple program to calculate addition, subtraction, division, and multiplication; however when i execute my program it only gets to entering a Y or N for continueing before it crashes however i don't get any errors from my compiler, i was wondering if it was one specific thing i was doing with my code or if i should just restart and try some other way todo it.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void)
{ float num1,num2,sum; char operation, ques;//defines float variables to hold user input and for calculations and defines character types for user input
printf("would you like todo a math problem? type y/n\n");//asks user for operators
scanf("%c",ques);//scans for user input and sets to character type variable QUES
while(ques=='y')//states that as long as user inputs a Y for answer to last input that it will continue to the math
{
printf("please enter a number you wish to to use: \n");//asks user for input
scanf("%f",&num1);//stores user input into num1 as float
printf("please enter an operator to which you would like to use with your number: \n");// asks user for input
scanf("%c",&operation);//stores user input to operation variable as character type variable
printf("please enter the next number you would like to use: \n");//asks user for input
scanf("%c",&num2);//stores user input to operation variable as character type variable
if (operation=='+')//states that if the character type variable operation is the addition sign it will print the sum of float num1 and float num2
printf("the sum is: %f\n",num1+num2 );//calculates number and prints result
if (operation=='-')
printf("the sum is: %f\n",num1-num2 );//same as above^ for subtraction
if (operation=='*')
printf("the sum is: %f\n",num1*num2 );//same as above^for multiplication
if (operation=='-')
printf("the sum is: %f\n",num1/num2 );//same as above^ for division
printf("would you like todo another problem?");//prompts user if he would like to restart and use more numbers
scanf("%c",&ques);//takes user answer
}
printf("Guess you don't need me anymore!");//end of program statement if user doesn't enter a 'Y' into ques variable
return 0;//"ends program by returning a 0 to to the function main()"//
}