Pattern Printing coding 5

CODE NO:- 07

Print the below pattern

#LOGIC

#Program( In C):

In  C language we use  ' // '  for Single line comment and /*---*/ for multi line comment

#include<stdio.h> // header file for i/p and o/p
int main()
{
int n,i,j,k;
printf("\n enter the no.of rows:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
         for(j=0;j<n-i-1;j++) // loop for printing spaces
  {
             printf(" ");
         }
         for(k=0;k<=i;k++) // loop for printing pattern
  {
printf("%d ",i+1); /*Observe after %d there is a white space so that 
               pattern is printed correctly */
         }
printf("\n");
}
return 0;
}

We got this output by using DEV C++ (IDE)



Link: For other pattern printing problems

Comments

Post a Comment

Popular posts from this blog

WHY PROGRAMMING?

Series code 2

Pattern Printing coding 7