Rules for identifiers in c language
1.
What will be output of the following c program?
#include <stdio.h>
int main(){
int goto =5;
printf( "%d" , goto );
return 0;
}
2.
What will be output of the following c program?
#include <stdio.h>
int main(){
long int 1a=5l;
printf( "%ld" ,1a);
return 0;
}
3.
What will be output of the following c program?
#include <stdio.h>
int main(){
int _=5;
int __=10;
int ___;
___=_+__;
printf( "%i" ,___);
return 0;
}
Explanation:
Variable name can have only underscore.
4.
What will be output of the following c program?
#include <stdio.h>
int main(){
int max-val=100;
int min-val=10;
int avg-val;
avg-val = max-val + min-val / 2;
printf( "%d" ,avg-val);
return 0;
}
5.
What will be output of the following c program?
#include <stdio.h>
int main(){
int class=150;
int public=25;
int private=30;
class = class >> private - public;
printf( "%d" ,class);
return 0;
}
6.
What will be output of the following c program?
#include <stdio.h>
int main(){
int abcdefghijklmnopqrstuvwxyz123456789=10;
int abcdefghijklmnopqrstuvwxyz123456=40;
printf( "%d" ,abcdefghijklmnopqrstuvwxyz123456);
return 0;
}
7.
What will be output of the following c program?
#include <stdio.h>
int main(){
register xyz_123=91;
auto pqr_123=991;
const _1a1_=pqr_123+~xyz_123;
printf( "%d" ,_1a1_);
return 0;
}
8.
What will be output of the following c program?
#include <stdio.h>
int main(){
int __SMALL__ = 11;
int y;
y= __SMALL__ < 5;
printf( "%d" ,y);
return 0;
}
9.
What will be output of the following c program?
#include <stdio.h>
int main(){
int __BIG__ = 32;
int y;
y= __BIG__ && 8;
printf( "%d" ,y);
return 0;
}
10.
What will be output of the following c program?
#include <stdio.h>
static num=5;
int num;
extern int num;
int main(){
printf( "%d" ,num);
return 0;
}
11.
What will be output of the following c program?
#include <stdio.h>
static num=5;
extern int num;
int main(){
printf( "%d" ,num);
return 0;
}
int num =25;
12.
What will be output of the following c program?
#include <stdio.h>
static num;
int main(){
printf( "%d" ,num);
return 0;
}
int num =25;
13.
What will be output of the following c program?
#include <stdio.h>
int xyz=10;
int main(){
int xyz=20;
printf( "%d" ,xyz);
return 0;
}
14.
What will be output of the following c program?
#include <stdio.h>
int main(){
int xyz=20;
int xyz;
printf( "%d" ,xyz);
return 0;
}
15.
What will be output of the following c program?
#include <stdio.h>
int main(){
int xyz=20;{
int xyz=40;
}
printf( "%d" ,xyz);
return 0;
}
16.
What will be output of the following c program?
#include <stdio.h>
int main(){
int main = 80;
printf( "%d" ,main);
return 0;
}
17.
What will be output of the following c program?
#include <stdio.h>
int main(){
struct a{
int a ;
};
struct a b={10};
printf( "%d" ,b. a );
return 0;
}
18.
What will be output of the following c program?
#include <stdio.h>
int main (){
int ABC=10;
printf( "%d" ,abc);
return 0;
}
19.
What will be output of the following c program?
#include <stdio.h>
int main(){
int printf=12;
printf( "%d" ,printf);
return 0;
}
20.
What will be output of the following c program?
#include <stdio.h>
int main(){
int EOF=12;
printf( "%d" ,EOF);
return 0;
}
17 comments:
good tricky question bro!!1
Good Qustions but expect more explanation.
Shivdas Kanade
good question !!!!!!!!!!!
awesome question ......good work
Very good work... but question 8 has wrong answer.
Answer of question 8 is correct. You may using different compiler. Check it in Turbo c 3.5 compiler.
Question 10 & 11 are giving error redefinition of ‘num’
with gcc compiler :-/
Nice questions........
great questions but question number 8,10,12 are incorrect
gud que's like it
in question 17 the stucture is not properly because the object which is defined is defined incoorectly
Can you pleaze explain question number 5.How does it give output 4?what is operator << doing?
nice questions .Good work
nice...
hiiiiii...this is SILKY BANKA ..i m nt getting ques no.7 and 8.
In question 5......
remember the value becomes half during every right shift(>>) and 150>>30-25
150>>5 times right shift
now ,150 becomes 75(1st time)
75 becomes 37(2nd time)
37 becomes 18(3rd time)
18 become 9 (4th time)
9 become 4 (5th time)
BY ABHINAV SAXENA
Tricky Questions dude...nice explanation
Post a Comment