C Programming and Problem Solving
Questions 31 to 40
31.
|
What is the output of the following
code fragment?
void main(){
printf("%x",-1<<4);
}
|
||||||||||
Find the output of the following
program
void main(){
char *msg=‘hi’;
printf(msg);
}
|
|||||||||||
Find the output of the following
program
void main() {
int
i = “hello”;
printf(i);
}
|
|||||||||||
Find the output of the following
program
void main() {
int
array[10];
int
*i=&array[2],*j=&array[5];
int
*k=i+j;
int
diff=j-i;
printf(“%d”,diff);
}
|
|||||||||||
Find the output of the following
program
void
main() {
printf(“%d,
%d”,sizeof(int *),sizeof(int **));
}
|
|||||||||||
What's wrong in this statement? (x == 4 && y == 5) ? (a =
5) ; (b = 6);
|
|||||||||||
Find the output of the following
program
void main() {
int i=10; /* assume address of i is 0x1234ABCD */
int *ip=&i;
int
**ipp=&&i;
printf(“%x,%x,%x”,&i,ip,*ip);
}
|
|||||||||||
Find the output of the following
program
void main() {
int i=01289;
printf(“%d”,i);
}
|
|||||||||||
Find the output of the following
program
void main() {
int
i=065,j=65;
printf(“%d%d”,i,j);
}
|
|||||||||||
Find the value of i that will be printed as the output of the following
program
void
main() {
int i=10;
i=!i>14;
printf
("i=%d",i);
}
|
Answers
A
|
1 is Shifted towards left by 4 positions and hence the
output is.
|
|
E
|
The character ‘hi’ is a multi-bye character, and the
programmer has typed ‘hi’ instead of “hi”
|
|
E
|
In the underlying implementation if the size of int and
the size of the pointer are same then there is no problem in storing address
of the string literal in integer printf is a dump routine and it will
interpret the first argument as a string.
|
|
C
|
We can’t
perform addition operation between two pointers.
|
|
D
|
Any type of pointer is get allocated by 2 bytes of
memory in turbo c.
|
|
B
|
According to the syntax of a ternary operator colon is
used along with the ? operator.
|
|
D
|
&& is logical AND operator and this operator
requires two operands.
|
|
D
|
The prefix 0 in an integer value indicates octal value.
In octal value use of 8 and 9 is not allowed and hence the error.
|
|
A
|
As octal 65 ( 065 ) is equivalent of decimal value 53.
|
|
D
|
In the expression !i>14 , NOT (!)
operator has more precedence than ‘ >’ symbol. ! is a unary logical
operator. !i (!10) is 0 (not of true is false). 0>14 is false
(zero).
|
in 32nd i think runtime error would come as 'hi' is considerd as a character to be stored at an index.
ReplyDeletehttps://ideone.com/o4JGzE
Games and Graphics Code Examples
ReplyDeletethank you.
ReplyDeletec++ tutorial
java tutorial