Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3.  
  4. int main(void)
  5. {
  6. float n1,n2;
  7. char sym,choice;
  8. printf("\nThis Program is a program for calculator\n\n");
  9. printf("Enter your first value");
  10. scanf("%f",&n1);
  11. printf("\nEnter the operation");
  12. scanf("%c",&n1);
  13. printf("\nEnter your second value");
  14. scanf("%f",&n1);
  15. if(sym=='+')
  16. printf("\n%f",n1+n2);
  17. else if(sym=='-')
  18. printf("\n%f",n1-n2);
  19. else if(sym=='*')
  20. printf("\n%f",n1*n2);
  21. else if(sym=='/')
  22. printf("%f",n1/n2);
  23. else
  24. printf("You have entered an invalid input");
  25. printf("\nDo you wish to continue[y/n]");
  26. scanf("%s",&choice);
  27. if(choice=='y'||choice=='Y')
  28. main();
  29. else if (choice=='n'||choice=='N'){
  30. return 0;
  31. }
  32. else
  33. printf("Invalid input program will restart again");
  34. main();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement