I have doubt in the output generated | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

I have doubt in the output generated

25th Aug 2018, 5:17 PM
Mithun Kumar A
Mithun Kumar A - avatar
5 Antworten
+ 4
you are passing x(for a) whose value is 24 and b=42 in function result=x+y=24+42=66 and then the result variable returns and its value get store in variable result (in main) result=sum(x); which is as same as result=sum(24);
27th Aug 2018, 9:44 AM
Saba Yashfeen
+ 1
What’s the function, the expected output, and the actual output?
25th Aug 2018, 5:49 PM
krikkitbot
krikkitbot - avatar
+ 1
the second function whose output is 66
26th Aug 2018, 4:18 AM
Mithun Kumar A
Mithun Kumar A - avatar
+ 1
What’s the code of the function?
26th Aug 2018, 5:56 PM
krikkitbot
krikkitbot - avatar
+ 1
#include <iostream> using namespace std; int sum(int a, int b=42) { int result = a + b; return (result); } int main() { int x = 24; int y = 36; //calling the function with both parameters int result = sum(x, y); cout << result << endl; //calling the function without b result = sum(x); cout << result << endl; return 0; }
26th Aug 2018, 6:09 PM
Mithun Kumar A
Mithun Kumar A - avatar