Pattern Printing coding 6


CODE NO:- 08

Print the below pattern

#LOGIC

Take a variable and assign it with value 0 then keep updating it in the inner loop and print the pattern.

#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,k,a=0;
printf("\n enter the no.of rows:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
         for(k=0;k<=i;k++)
  {
printf("%d ",++a);
         }
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