Following question are based on variable naming rules in c. If you have any doubt in the variable naming rules you can ask here.
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;
}
No comments:
Post a Comment