Hey guys
Today we are going to write a c program for printing number pattern like given below :-
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
For this you need two loops and and some variables for example i,j for two loops and n for number of rows. If you don't know about loops and variable visit notes section of our blog and read the whole pdf and understand the program algorithm.
Code for above pattern
#include<stdio.h>
#include<conio.h>
int main()
{
int n, i, j;
printf("Enter the number of rows: ");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
for(j = 1; j <= i; j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}
#include<conio.h>
int main()
{
int n, i, j;
printf("Enter the number of rows: ");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
for(j = 1; j <= i; j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}
Copy the above code run on any c compiler enter no of row then it will print no. Pattern.Try it now!
Let me enter number of rows = 6 then it will print
wow! It's amazing to see this now the program is running try out some new number pattern and keep visit our blog taknikijwalak.
Thank you 😊
Tags:
C programming