C Programming and Problem Solving Questions and Answers 271 to 280

C Programming and Problem Solving

Questions 271 to 280



271.
What is the output of the following code?
# include<stdio.h>
int main()
{
int i=1;
printf(“%d %d %d” ,++i,i++,++i);
return (0);
}
(a)
224
(b)
234
(c)
334
(d)
422
(e)
242.
272.
Which escape character can be used to begin a new line in C?
(a)
\a
(b)
\n
(c)
\l
(d)
\m
(e)
\t.
273.
How many actual arguments shall be used for a “normal function call” for each formal argument?
(a)
Two
(b)
Three
(c)
Zero
(d)
Any number of
(e)
One.
274.
What is the exact meaning of the following statement?
int *p(char *a [])
(a)
p is a function that accepts an argument which is an array of pointers to characters returns a pointer to an integer quantity
(b)
p is a pointer to function that accepts an argument which is an array of pointers to characters returns a pointer to an integer quantity
(c)
p is a function that accepts an argument which is a pointer to character array returns a pointer to an integer quantity
(d)
p is a pointer to function that accepts an argument which is an array of pointers to characters returns a pointer to character quantity
(e)
p is a function that accepts an argument which is an array of pointers to characters returns an integer quantity.
275.
What is the associativity of the conditional operator?
(a)
Left to right
(b)
Right to left
(c)
Top to bottom
(d)
Bottom to top
(e)
Top to left.
276.
What is a difference between a declaration and a definition of a variable?
(a)
Both can occur multiple times, but a declaration must occur first
(b)
There is no difference between them
(c)
A definition occurs once, but a declaration may occur many times
(d)
A declaration occurs once, but a definition may occur many times
(e)
Both can occur multiple times, but a definition must occur first.
277.
What is the output of the following program?
# include <stdio.h>
int main()
{
       int a=10, b=11, c=13, d;
       d = (a=c, b+=a, c=a+b+c);
       printf(“ %d”,  d);
       return(0);
}
(a)
34
(b)
50
(c)
Error
(d)
Garbage value
(e)
R value required.
278.
What is the final value of a, if the initial values are b=20, c=21, d=15, a=1?
a = d^b&c| b;
(a)
1
(b)
21
(c)
30
(d)
Syntax error
(e)
31.
279.
Choose the correct output for the following given program.
       # include <stdio.h>
       void fun(int a, int b, …)
       {
              int i=0, *p = &b;
              for( printf(“    ”);  i++<a;  )
                     printf(“%d, ”, ++(*p++));
       }
       int main()
       {
              fun(1, 0);
              fun(4,5,6,7,8);
              return(0);
       }
(a)
1,    4,5,6,7,
(b)
Syntax error
(c)
1,    6,7,8,9,
(d)
Run time error
(e)
0,    5,6,7,8,
280.
What is the return value of the following function if the function is called as
int value = fun(6);
int fun(int n)
{
if( n = = 1 ||  n = =  2)  return 1;
else   return( fun(n-1) + fun(n-2) );
}
(a)
1
(b)
2
(c)
Syntax error
(d)
8
(e)
5.

Answers


271.
Answer : (d)
Reason:  The last incremented i values is 4 so the values are displayed as 4 2 2.
272.
Answer : (b)
Reason:  The escape character can be used to begin a new line in C is \n.
273.
Answer : (e)
Reason:  In a normal function call, there will be one actual argument(s) for each formal argument.
274.
Answer : (a)
Reason:  p is a function that accepts an argument which is an array of pointers to characters returns a pointer to an integer quantity.
275.
Answer : (b)
Reason:  The associativity of the conditional operator is right to left.
276.
Answer : (a)
Reason:  The difference between a declaration and a definition of a variable is Both can occur multiple times, but a declaration must occur first.
277.
Answer : (b)
Reason:  Value 50 is assigned finally to d variable.
278.
Answer : (e)
Reason:  Value 31 is assigned to  variable ‘a ‘after performing all bitwise operations.
279.
Answer : (b)
Reason:  Syntax error will be displayed as a result.
280.
Answer : (c)
Reason:  Syntax error will be displayed as a result.


<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>





2 comments :