Print Square Number Pattern in C Programming

By | June 21, 2019

“Print Square Number Pattern in C Programming” is a C program to print a number pattern in the form of square as shown in the following figure:

Print Square Number Pattern in C Programming

Print Square Number Pattern in C Programming

The source code for printing a square of numbers pattern is presented in the following code block.

/*Write a C Program to print 
the square number pattern
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9
*/
#include <stdio.h>
int main()
{
    int row, col, num;
    for(row=1;row<=5;row++)
    {
        num = row;
		for(col=1;col<=5;col++)
        {
            printf("%d ",num);
            num++;
        }
        printf("\n");
    }

    return 0;
}

The output of this C program and sample run picture is as following

Output of Print Square Number Pattern in C Programming

Output of Print Square Number Pattern in C Programming

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *