'How to print Number Like following format in c? [closed]

how to print like this See This

c


Solution 1:[1]

#include <stdio.h>
int main(void) {
    for(int i=1; i<=10; i++) printf("%i\t%i\r\n", i, i+10);
    return 0;
}

Output:

1       11
2       12
3       13
4       14
5       15
6       16
7       17
8       18
9       19
10      20

Solution 2:[2]

#include <stdio.h>

typedef enum 
{
    O_VER,
    O_HOR,
    /* you can add your own */
}ORDER_t;

void printInCols(int startnum, int nCols, int nRows, ORDER_t order)
{
    for(int row = 0; row < nRows; row++)
    {
        for(int col = 0; col < nCols; col++)
        {
            switch(order)
            {
                case O_VER:
                    printf("%6d\t", startnum + row + col * (nCols + 1));
                    break;
                case O_HOR:
                    printf("%6d\t", startnum + col + row * (nCols));
                    break;
            }
        }
        printf("\n");
    }
}

int main()
{
    printInCols(4,6,7,O_HOR);
    printf("\n\n");
    printInCols(4,6,7,O_VER);
}

https://godbolt.org/z/WAj8Es

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LegendofPedro
Solution 2 0___________