int i = 4;
switch (i)
{
default:
;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);
Choice a: i = 5
Choice b: i = 8
Choice c: i = 9
Choice d: i = 10
Choice e: i = 18
Showing posts with label switch case. Show all posts
Showing posts with label switch case. Show all posts
Sunday, October 12, 2008
Friday, October 3, 2008
Identify errors in this below program, if any. Otherwise give the O/p
void main()
{
float a=1.1;
int x=1;
for(a=1.0; a<3.0; a++) {
switch(x)
{
default:
printf("its default\n");
case 1 :
printf("its 1\n");
x++;
continue;
case (1+1) :
printf("its 2\n");
break;
}
}
}
{
float a=1.1;
int x=1;
for(a=1.0; a<3.0; a++) {
switch(x)
{
default:
printf("its default\n");
case 1 :
printf("its 1\n");
x++;
continue;
case (1+1) :
printf("its 2\n");
break;
}
}
}
Subscribe to:
Posts (Atom)