53. WAP to understand for loop
#include<stdio.h>
void
main()
{
int part;
printf("Program to understand for
loop\n");
printf("Enter part number :
");
scanf("%d",&part);
switch(part)
{
case 1:;
int i1;
for(i1=0;i1<5;i1++)
printf("Hello\n");
break;
case 2:;
int i2;
printf("Hello...%d\n",i2);
for(i2=0;i2<3;i2++)
printf("Hi....%d\n",i2);
printf("Bye....%d\n",i2);
break;
case 3:;
int i3;
for(i3=0;i3<3;i3++);
printf("i =
%d\n",i3);
break;
case 4:;
int i4=0;
for( ;i4<3;i4++)
printf("%d\n",i4);
break;
case 5:;
int i5;
for(i5=0; ;i5++)
printf("%d\n",i5);
break;
case 6:;
int i6;
for(i6=0;i6<3; )
printf("%d\n",i6);
break;
case 7:;
unsigned int i7;
for(i7=2;i7>=0;i7--)
printf("%d\n",i7);
break;
case 8:;
int a,b;
//for(a=0,b=4;a<b;a++,b--)
for(a=0,b=4;a<b,a>b;a++,b--)
printf("a=%d
b=%d\n",a,b);
break;
}
}
Comments
Post a Comment