Archive for the ‘'C' puzzles’ Category

Tr!cky ‘C’ M@cros

Posted: December 21, 2009 in 'C' puzzles
Tags: ,
#include <stdio.h>
#define f(a,b) a##b
#define g(a)   #a
#define h(a)   g(a)
  int main()
  {
          printf("%s\n",h(f(1,2)));
          printf("%s\n",g(f(1,2)));
          return 0;
  }
H! fnds try to give the output of the above pgm with ur xplanations..

Solve this Quine

Posted: October 19, 2009 in 'C' puzzles
Tags: ,

Predict the output of this code snippet

#include<stdio.h>
char *p=”#include <stdio.h> %c%c char *p=%c%s%c; %c%c void main(){%c%c printf(p,13,10,34,p,34,13,10,13,10,13,10,13,10); %c%c }”;
void main()
{
printf(p,13,10,34,p,34,13,10,13,10,13,10,13,10);
}

Frnds this qn is simple.. I need ur answer with a proper xplanation.

printf x 20

Posted: May 20, 2009 in 'C' puzzles
Tags: ,

cvoid main()

{

int i;

for(i=0;i<20;i–)

printf(“Deepu”);

}

This code will print Deepu infinitely. Make this code to print Deepu exactly 20 times by changing only one ASCII character..[changing means appending a character or replacing one charater].

There are 3 possible solutions for this problem……

Note:
Obviously inserting 4 to make i=40 or inserting – to make i<-20 are NOT the answers
Mail me if u got answers or u need answers……….