What
is the output of following c program?
#include<stdio.h>
int main() {
int goto=5;
printf("%d",goto);
return 0;
}
Output: Compilation error.
Because it declared an invalid variable name. goto is a keyword in c language and variable name cannot be any
keyword.
What
is the output of following c program?
#include<stdio.h>
int main() {
long int 1a=5l;
printf("%ld",1a);
return 0;
}
Output:
Compilation error.
Because variable name cannot start with numeric value.
#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;
}
Output:
Compilation error.
Because variable name cannot have special character except underscore ( _ ).
What
is the output of following c program?
#include<stdio.h>
int xyz=10;
int main() {
int xyz=20;
printf("%d",xyz);
return 0;
}
Output:
20
Because two variables can have same name in different scope.
What
is the output of following c program?
#include<stdio.h>
int main() {
int ABC=10;
printf("%d",abc);
return 0;
}
Output:
Compilation error.
Because variable name is case sensitive.
What
is the output of following c program?
#include<stdio.h>
int main() {
int xyz=20;
int xyz;
printf("%d",xyz);
return 0;
}
Output:
Compilation error.
Because two local variables cannot have same name in same scope.
What
is the output of following c program?
#include<stdio.h>
void main() {
char *str="CQUESTIONBANK";
printf(str+9);
getch();
}
Output:
BANK
What
is the output of following c program?
#include<stdio.h>
extern struct student {
int a;
int b;
int c;
int d;
}s={6,7,8,9};
void main() {
printf("%d %d %d
%d",s.a,s.b,s.c,s.d);
getch();
}
Output:
6 7 8 9
What
is the output of following c program?
#include<stdio.h>
struct student {
int roll;
int cgpa;
int sgpa[8];
};
void main() {
struct student s={12,8,7,2,5,9};
int *ptr;
ptr=(int *)&s;
printf("%d",*(ptr+3));
getch();
}
Output:
2
What
is the output of following c program?
#include<stdio.h>
struct game {
int level;
int score;
struct player {
char *name;
}g2;
}g1;
void main() {
printf("%d %d
%s",g1.level,g1.score,g1.g2.name);
getch();
}
Output:
0 0 (null)