Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /*********************************
  2. * Class: MAGSHIMIM C1 *
  3. * Week 7 *
  4. **********************************/
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. #define MINIMUM_INT -2147483648
  10. #define MAXIMUM_INT 2147483647
  11.  
  12. void onesTriangle(int size);
  13.  
  14. int main(void)
  15. {
  16. int a = 0;
  17.  
  18. printf("Enter a number please: ");
  19. scanf("%d", &a);
  20.  
  21. while (a < MINIMUM_INT || a > MAXIMUM_INT)
  22. {
  23. getchar();
  24. printf("Invaild input, try again: ");
  25. scanf("%d", &a);
  26. }
  27.  
  28. onesTriangle(a);
  29.  
  30. return 0;
  31. }
  32.  
  33. /**
  34. The function recieves an int,
  35. And prints a triangle according to that.
  36.  
  37. Input:
  38. int size
  39. Output:
  40. None
  41. */
  42. void onesTriangle(int size)
  43. {
  44. int last = 1;
  45. int i = 0;
  46.  
  47. for (i = 0; i < size; i++)
  48. {
  49. printf("%d\n", last);
  50. last = (last * 10) + 1;
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement