0
To print numbers In pattern like 1 3, 1 3 5 ,1 3 5 7in C
Kindly update me
4 ответов
+ 8
Show your attempt first
+ 2
#include <stdio.h>
#include <string.h>
int main() {
int num = 1;
char array[100];
for (int i = 0; i < 10; i++) {
char array2[50];
sprintf(array2, "%d", num);
printf("%s ", strcat(array, array2));
num = num + 2;
}
return 0;
}
+ 2
Rudra priya
I am sure there should be pattern like this:
1
1 3
1 3 5
1 3 5 7
You can try this using for loop but always show your attempts.
for (int i = 1; i <= 10; i += 2) {
for (int j = 1; j <= i; j += 2) {
printf ("%d", j);
}
printf("\n");
}