Aspire Faculty ID #12781 · Topic: JECA MCA 2023 · Just now
JECA MCA 2023

26.What is the output of the following program ?  #include <iostream>  using namespace std;  template <class C1, class C2>  bool is_equal (C1 var1, C2 var2)  {   return (var1 = = var2);  }  int main ()  {   if (is_equal(10,10.0))    cout<< “Equal”;   else    cout<< “Not equal”;   return 0;  } 

Solution

The function `is_equal` is a template that compares two variables of possibly different types.  
In `main()`, we call `is_equal(10, 10.0)`.  

- `10` is an integer (int).  
- `10.0` is a double.  
C++ allows implicit type conversion during comparison.  
So, `10 == 10.0` evaluates to `true`.  

Therefore, the condition in the `if` statement is true, and the output will be:  

Equal

Previous 10 Questions — JECA MCA 2023

Nearest first

Next 10 Questions — JECA MCA 2023

Ascending by ID
Ask Your Question or Put Your Review.

loading...