0

To print numbers In pattern like 1 3, 1 3 5 ,1 3 5 7in C

Kindly update me

5th Feb 2022, 7:02 AM
Rudra priya
4 Antworten
+ 8
Show your attempt first
5th Feb 2022, 7:09 AM
ÃKR
ÃKR - avatar
+ 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; }
5th Feb 2022, 8:05 AM
Solus
Solus - avatar
+ 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"); }
5th Feb 2022, 8:21 AM
A͢J
A͢J - avatar