Hi
I want to print pattern something like
7, 8, 9, 10
4, 5, 6
2, 3
1
7 8 9 10Code:#include<stdio.h> int main () { int n; for ( n = 0; n <11; n++) { if (n > 6) { printf ("%d ", n); } } return 0; }
I do not understand what to do next
Hi
I want to print pattern something like
7, 8, 9, 10
4, 5, 6
2, 3
1
7 8 9 10Code:#include<stdio.h> int main () { int n; for ( n = 0; n <11; n++) { if (n > 6) { printf ("%d ", n); } } return 0; }
I do not understand what to do next
Better variable names to start with.
This prints information about the structure of the shape you want
Now, think about how you can replace printing n, with printing some other value derived from the variables you have.Code:for ( row = 0, items_on_row = 4 ; row < 3 ; row++, items_on_row-- ) { printf("Row %d will have %d numbers\n", row, items_on_row ); for ( n = 0 ; n < items_on_row ; n++ ) { printf("%d, ", n ); } printf("\n"); }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.