Only Assignment Call Increment Decrement C# Interview

This section on online C test focuses on “Increment and Decrement Operators”. One shall practice these test questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C online test questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of online C test questions on “Increment and Decrement Operators” along with answers, explanations and/or solutions:

1. What is the difference between the following 2 codes?

a) No difference as space doesn’t make any difference, values of a, b, d are same in both the case
b) Space does make a difference, values of a, b, d are different
c) Program 1 has syntax error, program 2 is not
d) Program 2 has syntax error, program 1 is not
View Answer

Answer: d
Explanation: None.

2. What is the output of this C code?

a) a = 1, b = 1
b) a = 2, b = 1
c) a = 1, b = 2
d) a = 2, b = 2
View Answer

Answer: b
Explanation: None.

3. What is the output of this C code?

a) 15, 4, 5
b) 9, 6, 9
c) 9, 3, 5
d) Undefined (Compiler Dependent)
View Answer

Answer: d
Explanation: None.

4. For which of the following, “PI++;” code will fail?
a) #define PI 3.14
b) char *PI = “A”;
c) float PI = 3.14;
d) none of the Mentioned
View Answer

Answer: a
Explanation: None.

5. What is the output of this C code?

a) a = 10, b = 9
b) a = 10, b = 8
c) a = 5, b = 9
d) a = 5, b = 8
View Answer

Answer: c
Explanation: None.

6. What is the output of this C code?

a) 0
b) 1
c) 2
d) Compile time error
View Answer

Answer: a
Explanation: None.

7. What is the output of this C code?

a) 6
b) 5
c) 4
d) Compile time error
View Answer

Answer: a
Explanation: None.

8. Comment on the output of this C code?

a) = operator is not a sequence point
b) ++ operator may return value with or without side effects
c) it can be evaluated as (i++)+i or i+(++i)
d) = operator is a sequence point
View Answer

Answer: a
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

Here’s the list of Best Reference Books in C Programming Language.

To practice all features of C programming language, here is complete set of 1000+ Multiple Choice Questions and Answers on C.

  1. #include <stdio.h> //Program 1
  2. int main()
  3. {
  4. int d, a =1, b =2;
  5. d = a+++++b;
  6. printf("%d %d %d", d, a, b);
  7. }
  1. #include <stdio.h> //Program 2
  2. int main()
  3. {
  4. int d, a =1, b =2;
  5. d = a+++++b;
  6. printf("%d %d %d", d, a, b);
  7. }
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a =1, b =1, c;
  5. c = a+++ b;
  6. printf("%d, %d", a, b);
  7. }
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a =1, b =1, d =1;
  5. printf("%d, %d, %d",++a +++a+a++, a+++++b,++d + d+++ a++);
  6. }
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a =10, b =10;
  5. if(a =5)
  6. b--;
  7. printf("%d, %d", a, b--);
  8. }
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int i =0;
  5. int j = i+++ i;
  6. printf("%d\n", j);
  7. }
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int i =2;
  5. int j =++i + i;
  6. printf("%d\n", j);
  7. }
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int i =2;
  5. int i = i+++ i;
  6. printf("%d\n", i);
  7. }
This section on C++ programming questions and answers focuses on “Increment and Decrement”. One shall practice these questions to improve their C++ programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C++ programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C++ programming questions come with detailed explanation of the answers which helps in better understanding of C++ concepts.

Here is a listing of C++ programming questions on “Increment and Decrement” along with answers, explanations and/or solutions:

1. Which operator works only with integer variables?
a) increment
b) decrement
c) both increment & decrement
d) none of the mentioned
View Answer

Answer: c
Explanation: None.

2. How many types are there in increment/decrement operator?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: There are two types of increment/decrement. They are postfix and prefix.

3. Pick out the correct statement.
a) Increment operator ++ adds 1 to its operand
b) Increment operator ++ adds 2 to its operand
c) Decrement operator ++ subtracts 1 to its operand
d) None of the mentioned
View Answer

Answer: a
Explanation: None.

4. What is the output of this program?

a) 21
b) 22
c) 23
d) 20
View Answer

Answer: a
Explanation: value of ‘a’ will be stored in c and then only it will be incremented.
Output:
$ g++ incre.cpp
$ a.out
21

5. What is the output of this program?

a) 55
b) 64
c) 46
d) 45
View Answer

Answer: b
Explanation: The values will be preincemented and predecremented, So it will print as 64.
Output:
$ g++ incre2.cpp
$ a.out
64

6. What is the output of this program?

a) 10
b) 11
c) 9
d) 12
View Answer

Answer: a
Explanation: In this program, the increment and decrement of evaluation of z will not be accounted because they are post.
Output:
$ g++ incre3.cpp
$ a.out
10

7. What is the output of this program?

a) 11
b) 12
c) 13
d) 14
View Answer

Answer: d
Explanation: In this program, we are adding the x value after preincrementing two times.
Output:
$ g++ incre4.cpp
$ a.out
14

8. What is the output of this program?

a) 532
b) 235
c) 312
d) 311
View Answer

Answer: d
Explanation: In this program, We are preincrementing and postincrementing the operands and saving it.
Output:
$ g++ incre5.cpp
$ a.out
311

9. Pick out the correct statement
a) Preincrement is faster than postincrement
b) postincrement is faster than preincrement
c) pretincrement is slower than postincrement
d) none of the mentioned
View Answer

Answer: a
Explanation: Because preincrement take one byte instruction & post increment takes two byte instruction.

10. Which concepts does the preincrement uses?
a) call by value
b) call by reference
c) queue
d) none of the mentioned
View Answer

Answer: b
Explanation: None.

Sanfoundry Global Education & Learning Series – C++ Programming Language.

Here’s the list of Best Reference Books in C++ Programming Language.

To practice all features of C++ programming language, here is complete set on 1000+ Multiple Choice Questions and Answers on C++.

  1. #include <stdio.h>
  2. usingnamespace std;
  3. int main()
  4. {
  5. int a =21;
  6. int c ;
  7. c = a++;
  8. cout<< c;
  9. return0;
  10. }
  1. #include <stdio.h>
  2. usingnamespace std;
  3. int main()
  4. {
  5. int x =5, y =5;
  6. cout<<++x <<--y << endl;
  7. return0;
  8. }
  1. #include <stdio.h>
  2. usingnamespace std;
  3. int main()
  4. {
  5. int x =5, y =5, z;
  6. x =++x; y =--y;
  7. z = x+++ y--;
  8. cout<< z;
  9. return0;
  10. }
  1. #include <stdio.h>
  2. usingnamespace std;
  3. int main()
  4. {
  5. int x =5, y =5, z;
  6. x =++x; y =--y;
  7. z = x +++x;
  8. cout<< z;
  9. return0;
  10. }
  1. #include <stdio.h>
  2. usingnamespace std;
  3. int main()
  4. {
  5. int num1 =5;
  6. int num2 =3;
  7. int num3 =2;
  8. num1 = num2++;
  9. num2 =--num3;
  10. cout<< num1 << num2 << num3;
  11. return0;
  12. }

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *