Subex Papers: Sample Questions 18 - 19 of 19

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 18

» Aptitude

Short Answer Question▾

Write in Short

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 number: 19

» Aptitude

Short Answer Question▾

Write in Short

What will be the output of the following code?

  1. #define exp 5
  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.