OCJP

Loop in Loop

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k=1;
char c='a';
clrscr();
for(i=1;i<=10;i++)
{
for(j=1;j<=i;j++)
{
if((i+j)%2==0)
{
printf("%d",k++);
}
else
{
printf("%c",c++);
}
}
printf("\n");
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *


Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.
× How can I help you?
Comodo SSL