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 *


× How can I help you?