I am trying to make a program that if the user gives a whole arithmetic operation from the keyboard ex 5*4
or 5/7
it will interpret the operation ex *
, /
, +
, or -
and print the result. How can I read the whole operation without the user pressing enter everytime he puts a number or a symbol ex *
or /
and put them in 3 variables?
I tried using:
printf("give an operation")
scanf("%d%c%d",&num_1,&c,&num_2)
but I want to do with:
c=getchar()