Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



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



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...