Multiple Choice Questions and Answers for Assigment Operators & Expressions in C Language

1. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int x = 0;
  5.         if (x = 0)
  6.             printf("Its zero\n");
  7.         else
  8.             printf("Its not zero\n");
  9.     }
a) Its not zero
b) Its zero
c) Run time error
d) None
Answer:a
2. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 8;
  5.         int x = 0 == 1 && k++;
  6.         printf("%d%d\n", x, k);
  7.     }
a) 0 9
b) 0 8
c) 1 8
d) 1 9
Answer:b
3. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         char a = 'a';
  5.         int x = (a % 10)++;
  6.         printf("%d\n", x);
  7.     }
a) 6
b) Junk value
c) Compile time error
d) 7
Answer:c
4. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         1 < 2 ? return 1: return 2;
  5.     }
a) returns 1
b) returns 2
c) Varies
d) Compile time error
Answer:d
5. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         unsigned int x = -5;
  5.         printf("%d", x);
  6.     }
a) Run time error
b) Aries
c) -5
d) 5
Answer:c
6. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 2, y = 1;
  5.         x *= x + y;
  6.         printf("%d\n", x);
  7.         return 0;
  8.     }
a) 5
b) 6
c) Undefined behaviour
d) Compile time error
Answer:b
7. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 2, y = 2;
  5.         x /= x / y;
  6.         printf("%d\n", x);
  7.         return 0;
  8.     }
a) 2
b) 1
c) 0.5
d) Undefined behaviour

Answer:a
8. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 1, y = 0;
  5.         x &&= y;
  6.         printf("%d\n", x);
  7.     }
a) Compile time error
b) 1
c) 0
d) Undefined behaviour
Answer:a
9. What is the type of the below assignment expression if x is of type float, y is of type int?
     y = x + y;

a) int
b) float
c) There is no type for an assignment expression
d) double
Answer:a 
10. What is the value of the below assignment expression
     (x = foo())!= 1 considering foo() returns 2

a) 2
b) True
c) 1
d) 0
Answer:a 
11. Operation “a = a * b + a” can also be written as:

a) a *= b + 1;
b) (c = a * b)!=(a = c + a);
c) a = (b + 1)* a;
d) All of the mentioned
Answer:d 
12. for c = 2, value of c after c <<= 1;

a) c = 1; 
b) c = 2; 
c) c = 3; 
d) c = 4;
 Answer:d [/expand] 

13. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 1, b = 2;
  5.         a += b -= a;
  6.         printf("%d %d", a, b);
  7.     }
a) 1 1
b) 1 2
c) 2 1
d) 2 2
Answer:c 
14. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 4, n, i, result = 0;
  5.         scanf("%d", n);
  6.         for (i = 0;i < n; i++)
  7.         result += a;
  8.     }
a) Addition of a and n.
b) Subtraction of a and n.
c) Multiplication of a and n.
d) Division of a and n.
Answer:c 
15. Which of the following is an invalid assignment operator?

a) a %= 10;
b) a /= 10;
c) a |= 10;
d) None of the mentioned
Answer:d

Related

Data Structure Questions and Answers on Topological Sort for Freshers

1. Topological sort can be applied to which of the following graphs? a) Undirected Cyclic Graphsb) Directed Cyclic Graphsc) Undirected Acyclic Graphsd) Directed Acyclic Graphs Answer: d Explan...

Java Multiple Choice Questions & Answers on Assignment Operators and Operator Precedence for Freshers

1. Which of these have highest precedence? a) ()b) ++c) *d) >> Answer: a Explanation: Order of precedence is (highest to lowest) a -> b -> c -> d. 2. What should be expression1 ev...

Oracle Database Multiple Choice Questions and Answers on Programmatic Oracle Structures for Freshers

1. What does DLL stand for ? a) Dynamic Link Libraryb) Dynamic Language Libraryc) Dynamic Load Libraryd) None of the Mentioned Answer: a Explanation: DLL, linking occurs at run time when the rout...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item