Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************
- * Class: MAGSHIMIM C1 *
- * Week 7 *
- **********************************/
- #include <stdio.h>
- #include <stdlib.h>
- #define MINIMUM_INT -2147483648
- #define MAXIMUM_INT 2147483647
- void onesTriangle(int size);
- int main(void)
- {
- int a = 0;
- printf("Enter a number please: ");
- scanf("%d", &a);
- while (a < MINIMUM_INT || a > MAXIMUM_INT)
- {
- getchar();
- printf("Invaild input, try again: ");
- scanf("%d", &a);
- }
- onesTriangle(a);
- return 0;
- }
- /**
- The function recieves an int,
- And prints a triangle according to that.
- Input:
- int size
- Output:
- None
- */
- void onesTriangle(int size)
- {
- int last = 1;
- int i = 0;
- for (i = 0; i < size; i++)
- {
- printf("%d\n", last);
- last = (last * 10) + 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement