+ 2

Questions about series

I want to have this 987...1 987..2 . . . 9 But I don’t know what I have to write It’s wrong https://code.sololearn.com/c6KeOr2wvQ64/?ref=app

10th Nov 2019, 5:04 AM
Laya Mousavi
12 Answers
+ 7
Try this #include <stdio.h> int main() { int i,n,j; for(i=9;i>=1;i--){ for(j=1;j<=i;j++){ n=10-j; printf("%d",n); } printf("\n"); } return 0; }
10th Nov 2019, 5:16 AM
Akash
Akash - avatar
+ 6
The two codes are exactly the same only
10th Nov 2019, 7:37 AM
Akash
Akash - avatar
+ 6
Just with different syntaxLaya Mousavi
10th Nov 2019, 7:37 AM
Akash
Akash - avatar
+ 5
Try this #include <stdio.h> int main() { int i,n,j; for(i=9;i>=1;i--){ for(j=1;j<=i;j++){ n=10-j; printf("%d",n); } printf("\n"); } return 0; }
10th Nov 2019, 5:16 AM
Akash
Akash - avatar
+ 5
So i did the same patter
10th Nov 2019, 7:17 AM
Akash
Akash - avatar
+ 5
I have messaged you in your inbox
10th Nov 2019, 7:27 AM
Akash
Akash - avatar
+ 1
987654321 987654322 ... ... 987654329 Is this what you mean?
10th Nov 2019, 5:12 AM
Ipang
+ 1
Your series(pattern) is not clear to me. Can elaborate please?(give first 5 numbers in the series) Also there's a bug in your first for loop. You have written for(i=1;i<=9;i--) In this case i is 1 when the program starts and it will decrease the i while it's less than or equal to 9. Well i is always less than 9 in this case so program will run infinitely. Try this for(i=9;i>1;i--)
10th Nov 2019, 5:16 AM
__IAS__
__IAS__ - avatar
+ 1
Laya Mousavi __IAS__ had told you the problem with your loop, please read his review. This is how I would do it BTW, you might want to cross check what I had changed from your original code : ) int main() { int i, n = 9, j; for (i = n; i; i--) { for (j = 0; j < i; j++) { printf("%d", n - j); } printf("\n"); } return 0; }
10th Nov 2019, 7:34 AM
Ipang
0
Trying... __IAS__ Ipang the pattern is this 987654321 98765432 9876543 987654 98765 9876 987 98 9
10th Nov 2019, 7:15 AM
Laya Mousavi
0
would u pls say what is my pattern problem?!(the code that i wrote)
10th Nov 2019, 7:22 AM
Laya Mousavi