126)
#include
main()
{
char c='6';
int d=6;
printf("%d %d %d",d,d+=c>'0'&&c<='7',c++);
}
127)
#include
main()
{
int a=4,b=2;
a=b<>2;
b=b<>2;
printf("%d %d",a,b);
}
128)
#include
main()
{
int i=98765;
printf("%d\n",printf("%d",printf("%d",i)));
}
129)
#include
main()
{
char c;
while(c=getchar()!='a')printf("%d",c);
}
//INPUT=dcba
130)
#include
main()
{
int *i=0;
printf(" %p\n",i);
}
131)
#include
#include
main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
}
132)
#include
unsigned getbits(unsigned a,int i,int j)
{
return(a>>(i+1-j)) & ~(~0<
main()
{
unsigned num=128;
printf("%d\n",getbits(num,7,5));
}
133)
#include
#define sq(x) x*x
main()
{
int a=5;
printf("%d\n",sq(a+5));
}
134)
#include
#define concatinate(a,b) a##b
#define same1(a) #a
#define same2(a) same1(a)
main()
{
printf("%s\n",same2(concatinate(1,2)));
printf("%s\n",same1(concatinate(1,2)));
}
135)
#include
main()
{
int a=1,b=3,c,d;
c=(a,b);
d=a,b,c;
printf("%d %d",c,d);
}
136)
#include
#include
main()
{
int*ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
}
137)
#include
main()
{
int x;
x=20;
printf("x:%d\n",x);
printf("sizeof(x++) is: %d\n",sizeof(x++));
printf("x:%d\n",x);
}
138)
#include
#define f(x,y) x##y
#define g(x) #x
#define h(x) g(y)
int main()
{
printf("%s\n",h(f(2,3)));
printf("%s\n",g(f(2,3)));
return 0;
}
139)
#include
int main()
{
int i;
i = 10,20,30;
printf("i:%d\n",i);
}
140)
#include
#define PrintInt(expr) printf("%s : %d\n",#expr,(expr))
int Shiftfn(int a)
{
int t;
t = a<<2 + a;
return t;
}
int main()
{
int i = 1, j = 2,k = 3;
PrintInt(Shiftfn(i));
PrintInt(Shiftfn(j));
PrintInt(Shiftfn(k));
}
141)
#include
enum {false,true};
int main()
{
int i=1;
do
{
printf("%d\n",i);
i++;
if(i < 15)
continue;
}while(false);
}
142)
#include
int main()
{
float a = 12.5;
printf("%d\n",a);
printf("%d\n", *(int *)&a);
return 0;
}
143)
#include
int main()
{
int a=1;
switch(a)
{ int b=20;
case 1: printf("b is %d\n",b);
break;
default:printf("b is %d\n",b);
break;
}
return 0;
}
144)
#include
#include
int s(char*A[20],char*B[20])
{
char *a,*b;
a=A,b=B;
while(*a++!=*b++);
*a=*b='\0';
return strlen(A);
}
int main()
{
char A[20]="somestring",B[20]="debugthecbug";
printf("%d %s %s\n",s(&A,&B),A,B);
return 0;
}
145)
#include
void insert(char a[],int n)
{
int i,j;
for(i=j=0;a[i]!='\0';i++)
if(a[i]!=n)
a[j++]=a[i];
a[j]='\0';
}
main()
{
char a[]="helloworld";
insert(a,'l');
printf("%s",a);
}
146)
#include
#include
void weird(int*a)
{
a=(int*)malloc(sizeof(int));
}
main()
{
int*a;
weird(a);
*a=6;
printf("%d\n",*a);
}
147)
#include
main()
{
int a=4,b=10;
printf("%d %d %d %d\n",a,a^=b=b^=a=a^=b,b,printf("%d %d %d\n",
b,a,a^=b=b^=a=a^=b));
}
148)
#include
int fun1()
{
static int c=20;
return --c;
}
int fun2()
{
static int c=1;
return fun1()+c--;
}
int main()
{
int i=0;
while(i
return 0;
}
149)
#include
#include
main()
{
char a[]="aaa";
char *b="bbb";
strcpy(a,"cc");
printf("%s",a);
strcpy(b,"dd");
printf("%s",b);
}
150)
#include
int array[]={1,2,3,4,5,6,7,8};
#define SIZE (sizeof(array)/sizeof(int))
int main()
{
printf("%d",SIZE);
if(-1<=SIZE) printf("1");
else printf("2");
return 0;
}
Search Your Question
Wednesday, July 23, 2008
C Programming Puzzles 6.
Labels:
programming
Subscribe to:
Post Comments (Atom)
Archives
-
▼
2008
(992)
-
▼
July
(288)
- Yahoo Interview
- Yahoo Interview Questions
- Yahoo Interview Questions-1
- Yahoo Interview Questions-2
- Visual Basic Interview Questions -7
- Visual Basic Interview Questions -6
- Visual Basic Interview Questions -5
- Visual Basic Interview Questions -4
- Visual Basic Interview Questions -3
- Visual Basic Interview Questions -2
- Visual Basic Interview Questions -1
- SQL Interview Questions -8
- SQL Interview Questions -7
- SQL Interview Questions -6
- SQL Interview Questions -5
- SQL Interview Questions -4
- SQL Interview Questions -3
- SQL Interview Questions -2
- SQl Job Interview Questions
- Solutions to C programming questions
- Modified Array based QuickSort with respect to the...
- Last Non Zero Digit of Factorial
- Quick Sort routine to find the kth smallest elemen...
- Run time Analysis of QuickSort ,Nature of Input,Pi...
- Tree Arithmetic
- Number of ways to express a number as summation of...
- Solutions to Logical Puzzles-2
- Combinations
- Solutions to Basic C Interview Questions
- Solutions to Logical Puzzles-1
- Solutions to Logical Puzzles-3
- C program to find the height of a binary search tree
- C program to determine the number of nodes in a bi...
- C program to delete a tree
- Minimum Value of a Binary Search Tree
- Solutions to Questions on recursion
- C program to create mirror copy of a tree
- Solutions to Amazon Intern Interview Questions
- Traversals of a Binary Tree
- Solutions to Google Top Interview Puzzles
- Solutions to problems in recursion analysis
- solution1
- C-program to make a copy of a tree
- C-program to check whether a binary tree is a Bina...
- C-program to delete a node from a tree
- Search On a Binary Search Tree
- C-program to count the leaves in a tree
- Some Basic Questions on sorting and their solutions
- Resume Tips
- Secrets of a Selling Resume
- The Three R's of Resume Writing
- Top Ten Pitfalls of a Resume
- Ten Tips for Writing Better Resumes
- Frequently Asked Questions - Object oriented Concepts
- Frequently Asked Questions - Operating System Conc...
- Frequently Asked Questions - Database
- Frequently Asked Questions - Networking
- UNIX Concepts
- Resources For Placements Preparation
- Essentials Of Operating Systems
- Networking Concepts
- Microsoft Puzzles
- Important Puzzles
- Important Puzzles
- Important Puzzles
- Important Puzzles
- Important Puzzles
- Important Puzzles
- Important Puzzles
- Important Puzzles
- Important Puzzles
- Practise Puzzles - 1
- Practise Puzzles - 1
- Practise Puzzles - 2
- Practise Puzzles - 2
- Practise Puzzles - 2
- Answers For Practise Puzzles - 1
- Answers for Practise Puzzles - 2
- Practise Puzzles - 3
- Practise Puzzles - 3
- Practise Puzzles - 3
- Answers for Practise Puzzles - 3
- Practise Puzzles - 4
- Practise Puzzles - 4
- Answers For Practice Puzzles - 4
- Puzzles
- Logical Puzzles-1
- Logical Puzzles -2
- Logical Puzzles-3
- Algorithms And Programming #4
- Algorithms And Programming #5
- Algorithms And Programming #6
- Algorithms And Programming #7
- Algorithms And Programming #8
- Algorithms And Programming #9
- Prime Numbers!
- C Programming Puzzles
- C Programming Puzzles 2
- C Programming Puzzles 3
- C Programming Puzzles 4
-
▼
July
(288)
No comments:
Post a Comment