Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- number_pattern_3.c
- https://www.facebook.com/699199285504086/photos/gm.7403677166327822/705600451530636/
- Square matrix with n=6 rows and columns.
- It starts with the number 1 and increases in each column by the row number.
- Each next row starts with the number that was the last in the previous row.
- 1 2 3 4 5 6
- 6 8 10 12 14 16
- 16 19 22 25 28 31
- 31 35 39 43 47 51
- 51 56 61 66 71 76
- 76 82 88 94 100 106
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- int main(void){
- int r, c, num=0, n=6; // Square matrix with n=6 rows and columns.
- for(r=1;r<=n;r++){ // for all rows r
- for(c=0;c<n;c++) // for all columns c
- printf("%4d",num+=r); // num increases in each column by the row number
- num-=r+1; // Each next row starts with the number that was the last in the previous row.
- printf("\n\n"); // space between rows
- }
- return 0;
- } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement