How To Print Number Pattern.

What will be the solution of number pattern for right angle triangle?
Number pattern

Fig :-1


Programming
#include<stdio.h>
#include<conio.h>
int main()
{
int row, col,count,diff;  //Data type deceleration
for(row=1;row<=5;row++)   //For row
{
diff=5-1;             //this is difference for number pattern 
count=row;            //count is equal to row
for(col=1;col<=row;col++)  // for column
{
printf(" %d",count);   //printing number pattern
count+=diff;           //adding difference in count to print number pattern fro 2nd column and onward
diff--;                // decreasing difference by 1.
}
printf("\n");              //for new line
}
getch();
return 0;
}

Output
Output of the above program

Fig:-2
If you did not understand this code then go to my YouTube Video of this programming. And also comment in comment section so that I can help you.

Comments

Post a Comment

Popular posts from this blog

Abundant Number in C Programming || Learning Duniya

Automorphic Number in C Programming || Learning Duniya

How to Print Given Star Pattern