Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. /* program p1.c */
  2. # include <stdio.h>
  3. main()
  4. {
  5. int a,b;
  6. double x;
  7. char op;
  8. printf("podaj a:\n");
  9. scanf("%d",&a);
  10. printf("podaj b:\n");
  11. scanf("%d",&b);
  12. printf("podaj op:\n");
  13. fflush(stdin);
  14. scanf("%c",&op);
  15. switch(op)
  16. {
  17. case '+':x=a+b;
  18. break;
  19. case '-':x=a-b;
  20. break;
  21. case '/':x=a/b;
  22. break;
  23. case '*':x=a*b;
  24. break;
  25. case '%':x=a%b;
  26. break;
  27. default:printf("bledny operator. Koniec programu.\n");
  28. }
  29. printf("\n%d %c %d = %g\n",a,op,b,x);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement