fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. float num1,num2,Ans;
  6. int key;
  7. printf("Input Number1:");
  8. scanf("\n%f",&num1);
  9. printf("Input Number2:");
  10. scanf("\n%f",&num2);
  11. printf("Input key for opration");
  12. printf("\n 1=+,2=-3=/,4=*");
  13. scanf("\n%d",&key);
  14. if(key==1)
  15. {
  16. Ans=num1+num2;
  17. }
  18. else if(key==2)
  19. {
  20. Ans=num1-num2;
  21. }
  22. else if(key==3)
  23. {
  24. Ans=num1/num2;
  25. }
  26. else if(key==4)
  27. {
  28. Ans=num1*num2;
  29. }
  30. else
  31. {
  32. printf("ERROR");
  33. }
  34. printf("\nAns is %f",Ans);
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5628KB
stdin
1
4
2
stdout
Input Number1:Input Number2:Input key for opration
 1=+,2=-3=/,4=*
Ans is -3.000000