Home » C Programming » Data Types » Question
  1. Which of the following statements are correct about the program given below?
    #include <stdio.h>
    int main ()
    {
    float k = 0.7;
    if (k < 0.7)
    printf ("C\n");
    else
    printf ("C++\n");
    return 0 ;
    }
    1. The program will output C
    2. The program will output C++
    3. Compiler will report an error saying a float cannot be compared with a double.
    4. Output will be C for 16-bit compilers and C++ for 32-bit compilers
Correct Option: A

if(k < 0.7) here k is a float variable and 0.7 is a double constant. The float variable k is less than double constant 0.7. Hence the if condition is satisfied and it prints 'C'



Your comments will be displayed only after manual approval.