Questions about series | Sololearn: Learn to code for FREE!

+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

11/10/2019 5:04:15 AM

Laya Mousavi

12 Answers

New Answer

+6

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; }

+5

The two codes are exactly the same only

+5

Just with different syntaxLaya Mousavi

+4

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; }

+4

I have messaged you in your inbox

+3

So i did the same patter

+2

https://code.sololearn.com/cuwVQcUP73yc/?ref=app

+1

987654321 987654322 ... ... 987654329 Is this what you mean?

+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--)

+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; }

0

Trying... __IAS__ Ipang the pattern is this 987654321 98765432 9876543 987654 98765 9876 987 98 9

0

would u pls say what is my pattern problem?!(the code that i wrote)