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

25.What is the output of the following program ?  include <iostream>  using namespace std;  int addition (int a, int b)  {   return a+b;  }  double addition (double a, double b)  {   return a+b;  }  int main ()  {   cout<< addition (35,20) << “;”;   cout<< addition (34.1,12.7);   return 0;  } 

Solution

The given program defines two overloaded functions `addition`:  
1. `int addition(int a, int b)` → returns integer sum  
2. `double addition(double a, double b)` → returns double sum  

In `main()`:
- `addition(35,20)` calls the integer version → 35 + 20 = 55  
- `addition(34.1,12.7)` calls the double version → 34.1 + 12.7 = 46.8  

Therefore, the output is:  
55;46.8

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...