0% found this document useful (0 votes)
124 views21 pages

C Puzzles by Raju (SRK)

This document contains 20 code snippets with questions about the output. The code snippets cover topics like preprocessor directives, operators, arrays, pointers, functions, loops and conditional statements. Each snippet is followed by "ans:" indicating the expected output is to follow.

Uploaded by

srkmnr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views21 pages

C Puzzles by Raju (SRK)

This document contains 20 code snippets with questions about the output. The code snippets cover topics like preprocessor directives, operators, arrays, pointers, functions, loops and conditional statements. Each snippet is followed by "ans:" indicating the expected output is to follow.

Uploaded by

srkmnr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

simple

C
Puzzles
main()
{
int i=400,j=300;

printf("%d%d");

}
ans:
#define ABC 200
#define XYZ 10
#define XXX ABC / XYZ
void main()
{
int a;
a = XXX * 10;
printf("%d ", a);
}ans:
main()
{
printf("\nab");

printf("\bsi");

printf("\rha");

}ans:
main()
{

int c=- -2;

printf("c=%d",c);
}ans:
#define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}ans:
main()
{
int i;
printf("%d",scanf("%d",&i));
// value 10 is given as
input here

}ans:
#define int char
main()
{
int i=65;
printf("sizeof(i)=
%d",sizeof(i));
}ans:
Void main()
{
int x=4,y,z;
y=--x;
z=x--;
printf(“%d %d %d”,x,y,z);
}ans:
void main()

printf(“%c”,”abcdef”[4]);

}ans:
void main()
{
int x=4,y=2,z;
z=x-- -y;
printf(“%d %d %d”,x,y,z);
}ans:
#include <stdio.h>
void main ()
{ int i=1;
switch(i-2)
{ case -1:printf(“a”);
case 0:printf(“b”);
case 1:printf(“c”);
default:printf(“none”);
}
}ans:
#include <stdio.h>
void main ()
{ int i=1;
switch(i)
{ printf(“b”);
case 1:printf(“a”);break;
case 2:printf(“aa”);break;
}
}ans:
#include <stdio.h>
void main()
{
float a=3.15555;
printf(“\n%5.4f”,a);
printf(“\n%0.0f”,a);
}ans:
#include<stdio.h>
void main()
{
int a=500,b=100,c;
if(!a>=400)
b=300;
c=200;
printf(“b=%d c=%d”,b,c);
}ans:
How many times a get printed?
Void main()
{
int x;
for(x=-1;x<=10;x++)
{ if(x<5)
continue;
else
break;
printf(“a”);
}}ans:
#include <stdio.h>
void main()
{ int a[5]={5,1,15,20,25};
int i,j,k;
i=++a[1];
j=a[1]++;
k=a[i++];
printf(“\n%d %d %d”,i,j,k);
}ans:
#include <stdio.h>

main()
{
int a = 5;
printf("%d %d\n", a++, ++a);

} ans:
What is the output of the following
code?
# include<stdio.h>
# define a 10
main()
{ printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}ans:
#include <stdio.h>
void main()
{
int I=3,*j,**k;
j=&I;
k=&j;
printf("%d%d
%d",*j,**k,*(*k));
}ans:
Presentation
by
m.n.raju
(08X41A1230)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy