+ 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
12 Antworten
+ 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;
}
+ 6
The two codes are exactly the same only
+ 6
Just with different syntaxLaya Mousavi
+ 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;
}
+ 5
So i did the same patter
+ 5
I have messaged you in your inbox
+ 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
would u pls say what is my pattern problem?!(the code that i wrote)