Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5. int x, a, b, c, suma;
  6. poczatek:
  7. printf("Podaj liczbe 3-cyfrowa: ");
  8. scanf("%d", &x);
  9. if (x<100 || x>999)
  10. {
  11. printf("Liczba musi byc trzycyfrowa!\n");
  12. goto poczatek;
  13. }
  14. a=x/100;
  15. b=x/10;
  16. b=b%10;
  17. c=x%10;
  18. suma=a+b+c;
  19. printf("%d\n%d\n%d\n", a, b, c);
  20. printf("Suma cyfr podanej liczby: %d + %d + %d = %d", a, b, c, suma);
  21. getch();
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement