Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 250 - 251 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 250

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. main ()
  2. {
  3.     floati =1.5;
  4.     switch (i)
  5.     {
  6.         case1:Printf ( “1” );
  7.         case2:Printf ( “2” );
  8.         default:Printf ( “0” );
  9.     }
  10. }

Explanation

  • In the program
Table Shows the Program
float i = 1.5;
  • Given the float variable i = 1.5
switch (i)

{

case 1: Printf ( “1” ) ;

case 2: Printf ( “2” ) ;

default: Printf ( “0” ) ;

}

  • Given the switch condition
  • But switch statements can be applied only to integral types.
  • Hence, compiler error: switch expression not integral

Question 251

C & C Plus Plus
Edit

Describe in Detail

Essay▾

In a header file whether functions are declared or define?

Explanation

Define Parts of Functions
  • In header files the function are declared not defined it՚s defined in the library routines.
  • A header file is a file containing C declarations and macro definitions shared between several source files.

Header File Serves Two Purposes

  • System header files declare the interfaces to parts of the operating system. Program can include them to supply the declarations needed to invoke system calls. Corresponding libraries providing functionality (definitions) are often linked at run time.
  • Group of related declarations and macro definitions spread across different source files should be combined in a header file.

Developed by: