C Programming and Problem Solving
Questions 41 to 50
41.
|
Find the
output of the following program:
void main(){
struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }
|
||||||||||
Find the
output of the following program:
void main() {
printf("\nab"); printf("\bsi"); printf("\rha"); }
|
|||||||||||
Pick the correct output of the following program
#define
square(x) x*x
void main() {
int i;
i =
64/square(4);
printf("%d",i);
}
|
|||||||||||
What is the correct output for the following piece of code?
#define a 10
void
main() {
#define a 50
printf("%d",a);
}
|
|||||||||||
The output of the following program
is
void main() {
printf("%p", main);
}
|
|||||||||||
What is the output of the following
code part?
enum
colors {BLACK,BLUE,GREEN}
void main()
{
printf("%dà%dà%d",BLACK,BLUE,GREEN);
}
|
|||||||||||
The output of the following program
is
#define f(g,g2) g##g2
void main() {
int
var12=100;
printf("%d",f(var,12));
}
|
|||||||||||
The output of the following program
is
void main( ) {
int a[ ] = {10,20,30,40,50},j,*p;
for(j=0;
j<5; j++) {
printf(“%d”
,*a);
a++;
}
p = a;
for(j=0;
j<5; j++) {
printf(“%d
” ,*p);
p++;
}
}
|
|||||||||||
The type of the controlling
expression of a switch statement cannot be of the type
|
|||||||||||
What's wrong in the following statement, provided k is a variable of
type int?
for (k = 2, k <=12, k++)
|
Answers
41.
|
C
|
You can not initialize members in structure
declaration.
|
D
|
because of these three characters \n -
newline \b - backspace \r -
carriage return.
|
|
B
|
the macro call square(4) will substitute 4*4 at macro
call, so the expression becomes i = 64/4*4 . Since / and * has equal priority
the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64
|
|
E
|
The preprocessor directives can be redefined anywhere
in the program. So the most recently assigned value will be taken with the
current scope.
|
|
C
|
Function names are just addresses (just like array
names are addresses).
main() is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They are printed as hexadecimal numbers. |
|
A
|
enum members are get assigned with integer values
starting from 0, if not explicitly initialized in declaration.
|
|
D
|
## is token pasting operator which simply combines all
the parameters of macro into one variable.
|
|
C
|
Error is in line with statement a++. The operand must
be an lvalue and may be of any of scalar type for the any operator, array
name only when subscripted is an lvalue. Simply array name is a
non-modifiable lvalue.
|
|
D
|
According to the syntax of C programming language.
|
|
E
|
In for loop the three statement parts are separated by
two semicolons which are missing here.
|
you wont get your audience here try somewhere else.
ReplyDeleteCircle Through Three Points
ReplyDeleteHi,Lots of useful information. Thanks for sharing.
ReplyDelete