Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 66 - 67 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 66

C & C Plus Plus

Describe in Detail

  1. main ()
  2. {
  3.     floatme =1.1;
  4.     doubleyou =1.1;
  5.     if (me == you)
  6.     printf ( “IloveU” );
  7.     else
  8.     printf ( “IhateU” );
  9. }


  • For floating point numbers (float, double, long double) the values cannot be predicted exactly
  • Float takes 4 bytes
  • Double and long double takes 10 bytes
  • So, float stores 0.9 with less precision than long double.
  • So in the program
    Table Shows the Program
    float me = 1.1Define float value
    double you = 1.1Define double value
    if (me == you)Apply if condition for float and double value
  • Float me = 1.1 and double you = 1.1 is not same
  • So, apply the else condition and print I hate U
  • Rule of Thumb: Never compare when using floating point numbers with relational operators (== , >< ⇐ >= , =) .

Question 67

C & C Plus Plus

Write in Short

Short Answer▾

What is difference between pass by reference and pass by value?


Difference between Pass by Value and Pass by Reference
Pass by valuePass by reference
Passes an argument by valuePasses an argument by reference.
Sends copy of the data.Passes memory address of the data that is stored.
Change by the called function does not affect the actual value.Changes done by the called function effect the original data.

Developed by: