
II-122 Programming Concepts
6. Display ASCII values and corresponding characters
void main()
{
char x;
int i;
clrscr();
for(i=65;i<=68;i++)
{
printf("%d %c",i,i);
}
getche();
}
OUTPUT:
65 A 66 B 67 C 68 D
7. Leap year program
void main()
{
int y,x=0;
clrscr();
for(y=2000;y<=2007;y++)
{
if(y%4==0 && y%100!=0 || y%400==0)
{
printf("%d",y);
x++;
}
}
printf("\n\n%d",x);
getche();
}
OUTPUT:
2000 2004
2
8. Largest from an array
void main()
{
int x[5]={5,15,3,10,7};
int i;
clrscr();
for (i=0;i<5;i++)
M06_ITL-ESL4791_02_SE_C06.indd 122 12/22/2012 5:02:22 PM