Sunday, August 20, 2006

Predict the output of the following Functions.

Predict the output of the following Code Snippets.
This is an exercise based on Functions.
The answers are provided at the bottom of the exercise. Be honest with yourself. :P

//1
main()
{

printf("\nOnly stupids use c?");
display();
}

display()
{
printf("\nFools too use C!");
main();

}





//2
main()
{
printf("\nC to it that C survives.");

main();
}





//3
main()

{
int i=45, c;
c=check(i);

printf("\n%d", c);
}
check (int ch)

{
if (ch>=45)
return (100);

else
return (10*10);
}





//4
main()
{
int i=45, c;

c=check(i*1000);
printf("\n%d", c);

}
check (int ch)
{
if (ch>=40000)

return (ch/10);
else
return (10);

}




//1) infinite loop of both the statements

//2)The message " C to it that C survives" is iterated infinitesimally!

//3) 100

//4) 4500











The file can be downloaded at:
Download File

1 comment:

surya said...

become a follower for free C,C++ And vb code of my blog:
http://www.a2zhacks.blogspot.com to learn C,C++,VB programming.