Computer Science, asked by nandrajogyukti1405, 2 months ago

2. C++ programs to find meaning of three
number
use multiple if statement

Answers

Answered by MCPETH
1

Answer

#include <iostream>  

using namespace std;  

// non-void return type  

// function to calculate sum  

int SUM(int a, int b)  

{  

int s1 = a + b;  

return s1;  

}  

// returns void  

// function to print  

void Print(int s2)  

{  

cout << "The sum is "<< s2;  

return;  

}  

int main()  

{  

int num1 = 10;  

int num2 = 10;  

int sum_of = SUM(num1, num2);  

Print(sum_of);  

return 0;  

}  

Explanation:

C return: The return in C or C++ returns the flow of the execution to the function from where it is called. This statement does not mandatorily need any conditional statements. As soon as the statement is executed, the flow of the program stops immediately and return the control from where it was called. The return statement may or may not return anything for a void function, but for a non-void function, a return value is must be returned.

Similar questions