Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* program p1.c */
- #include <stdio.h>
- main()
- {
- int a,b,i=1;
- double l;
- char oper;
- printf("Podaj a:\n");
- scanf("%d",&a);
- printf("Podaj b:\n");
- scanf("%d",&b);
- printf("Podaj op:\n");
- fflush(stdin);
- scanf("%c",&oper);
- switch(oper)
- {
- case '+':l=a+b;
- break;
- case '-':l=a-b;
- break;
- case '/':l=(double)a/b;
- break;
- case'*':l=a*b;
- break;
- case'%':l=a%b;
- break;
- default:printf("bledny operator. Koniec programu.\n");
- i=0;
- }
- if(i)
- printf("\n%d %c %d = %g\n",a,oper,b,l);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement