Subex Placement: Sample Questions 18 - 19 of 19

Doorsteptutor material for competitive exams is prepared by world's top subject experts: get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 18

Edit

Write in Short

Short Answer▾

What will be the output of the following code?

switch (floatvalue)

Explanation

  • Following are the illegal ways of switch case statement in C Programming language which results in compilation error.
  • Floating point values are not allowed as Case Label.
  • Case Labels Should be Unique.
  • Variables are not allowed in switch case.
  • Comparison operators are not at all accepted.
  • All statements inside switch must be wrapped inside any of the case.
  • So if we passes any float value inside the switch () statement it will result in a compilation error.

Question 19

Edit

Write in Short

Short Answer▾

What will be the output of the following code?

  1. #defineexp5
  2. printf("%d",exp++);

Explanation

  • Here exp is preprocessor macro symbol which process first before the actual compilation. First preprocessor replace the symbol to its value in entire the program before the compilation. So in this program exp will be replaced by 5 before compilation. Thus program will be converted like this:
  1. main()
  2. {
  3.     printf(“%d”,5++);
  4. }
  • This will generate error because we cannot assign constant value directly. Hence compiler will give error.

Developed by: