Pattern Printing coding 9
CODE NO:- 11
Print the below pattern
#LOGIC
Take a variable and assign it with value 2 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>
int main()
{
int n,i,j,k,a=2;
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); // updating the variable ++a is same as a=a+1
}
printf("\n");
}
return 0;
}
We got this output by using DEV C++ (IDE)
Link: For other pattern printing problems
Print the below pattern
#LOGIC
Take a variable and assign it with value 2 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>
int main()
{
int n,i,j,k,a=2;
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); // updating the variable ++a is same as a=a+1
}
printf("\n");
}
return 0;
}
We got this output by using DEV C++ (IDE)
Link: For other pattern printing problems
Gud, informative
ReplyDelete