Monday 9 September 2013

C Programming for beginners, Patterns using nested for loop, Pattern 18

Pattern 18

write a prog. to print following pattern

0
22
444
6666
88888

#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,m=0,i,j;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
for(i=1;i<=n;i++,m+=2)
{
if(m>8)
{
m=0;
}
for(j=1;j<=i;j++)
{
printf("%d",m);
}
printf("\n");
}
getch();
}


O/P:


No comments:

Post a Comment

Contact Form

Name

Email *

Message *