G
gopala
Hey people,
Can somebody explain me how this fragment works ? I came across
this question in a competition and was really blank about this at the
time.
Actually I traced the program later but I still have doubts as to why
the compiler seems to neglect "case, default .. " keywords. Thanks in
advance.
#include <stdio.h>
void func() /*Code by me after some tracing */
{
char str[] = " ++c dna c evol I";
int sz = sizeof(str)/sizeof(char);
int i=sz-1;
printf("\n");
switch(8)
{
case 2:while(i)
{
defaultrintf("%c",str[i--]);}
}
}
int main()
{
int i=0;
/* Actual code in competition */
switch(0)
{
case 1: for(;i<5;i++)
case 10:{ printf("%d",i);
while(i%3!=0)
case 5: printf("%d",++i);
default: printf("*");
}
}
printf("\n\n\n");
func();
scanf("%d");
return 0;
}
Can somebody explain me how this fragment works ? I came across
this question in a competition and was really blank about this at the
time.
Actually I traced the program later but I still have doubts as to why
the compiler seems to neglect "case, default .. " keywords. Thanks in
advance.
#include <stdio.h>
void func() /*Code by me after some tracing */
{
char str[] = " ++c dna c evol I";
int sz = sizeof(str)/sizeof(char);
int i=sz-1;
printf("\n");
switch(8)
{
case 2:while(i)
{
defaultrintf("%c",str[i--]);}
}
}
int main()
{
int i=0;
/* Actual code in competition */
switch(0)
{
case 1: for(;i<5;i++)
case 10:{ printf("%d",i);
while(i%3!=0)
case 5: printf("%d",++i);
default: printf("*");
}
}
printf("\n\n\n");
func();
scanf("%d");
return 0;
}