Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(void)
- {
- float n1,n2;
- char sym,choice;
- printf("\nThis Program is a program for calculator\n\n");
- printf("Enter your first value");
- scanf("%f",&n1);
- printf("\nEnter the operation");
- scanf("%c",&n1);
- printf("\nEnter your second value");
- scanf("%f",&n1);
- if(sym=='+')
- printf("\n%f",n1+n2);
- else if(sym=='-')
- printf("\n%f",n1-n2);
- else if(sym=='*')
- printf("\n%f",n1*n2);
- else if(sym=='/')
- printf("%f",n1/n2);
- else
- printf("You have entered an invalid input");
- printf("\nDo you wish to continue[y/n]");
- scanf("%s",&choice);
- if(choice=='y'||choice=='Y')
- main();
- else if (choice=='n'||choice=='N'){
- return 0;
- }
- else
- printf("Invalid input program will restart again");
- main();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement