I have a question
"Write a C program that accepts as input a single integer k, then writes a pattern consisting of a single 1 on the first line, two 2s on the second line, three 3s on the third line, and so forth, until it writes k occurrences of k on the last line."
For example, if the input is 5, the output should be the following:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
I have written the below code to achieve this.
#include <stdio.h>
#include <stdlib.h>
int main() {
int k = 5;
int i;
int j;
for(i = 1; i<=k; i++){
for(j = 1; j<=i; j++){
printf('%d',i);
}
printf('\n');
}
return 0;
}
When I run this program, Eclipse crashes. Is there something I am missing in the code I wrote ?
printf('%d',i);.