2. Write a program that creates the following pattern:
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
C programming?
Yeah, we all had to do that in college too: CS102 ;-)
int i, j;
for (i = 9; i %26gt; 0; i--)
{
for (j = 1; j %26lt;= i; j++)
{
fprintf(stdout, "%d", j);
}
fprintf(stdout, "\n");
}
Reply:#include %26lt;stdio.h%26gt;
int main() {
int i,j;
for(i=9;i%26gt;=1;i--) {
for(j=1;j%26lt;=i;j++) printf("%d ",j);
printf("\n");
}
return 0;
}
Reply:for (int i = 9; i %26gt; 0; i--)
{
for(int j = 1; j %26lt;= i; j++)
{
cout %26lt;%26lt; j %26lt;%26lt; " ";
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment