+ 1
I made a simple calci program in C bt it isn't showing option to enter num1, num2 & operater .
8 Respostas
+ 7
Their is no errors showing in sololearn playground you have to enter all values at run time. Try all three inputs after run . I did changed little bit enter two number theñ operations.
#include <stdio.h>
int main()
{
float num1;
float num2;
char op;
float result;
printf ("enter the first number:");
scanf ( "%f",&num1);
printf ("\nenter the second number:");
scanf("%f",&num2);
printf ("\nenter the operation:");
scanf ( " %c",&op);
switch (op)
{
case '-':
result = num1 - num2;
printf ("\n%f",result);
break ;
case '+':
result = num1 + num2;
printf ("\n%f",result);
break ;
case '*':
result = num1 * num2;
printf ("\n%f",result);
break ;
case '/':
result = num1 / num2;
printf ("\n%f",result);
break ;
default :
printf ("this is not valid:");
}
}
+ 6
If you want to perform all task then remove break statement if u enter + then after + all cases will print automatically becoz their will be no break so
+ 2
Hey! Guess the order of your input, then type it box , you will get your expected output easily . Like that: 6 - 3
You'll get: 3.
+ 2
By your code: you can guess what operation you want to do, like that if you want to devide to numbers than simply type in box: '3 / 2',if you want to multiply tham, than type '2 * 6', if you want to substraction of two numbers than type '5 - 2' and if you want sum of two numbers than type '2+7' , you'll get you expected output. That's are only examples..
I hope it helps you :-)
+ 2
I know this example bt I wanna enter in output section these plus , subs,mult & div . Tell me about that how I will found my expected output ??
+ 2
You have to give all the input values at runtime.
+ 1
Raj Upadhyay You just need to enter the data in the input box in one shot. Like
10
*
23
And then press submit button. Remember to press the enter after each.
I already tried and it works.
+ 1
Rupali.Bt how will I geuss the order of my input & how will it type in box ? please explain in simple way because I am beginner & I don't know too much in coding