OO T-Mobile 9:19 AM 63% Lesson 10 Functions Adv Mod Te... T Programming Logic an
ID: 3806297 • Letter: O
Question
OO T-Mobile 9:19 AM 63% Lesson 10 Functions Adv Mod Te... T Programming Logic and Design Seventh Edition Line 5 declares our module. it 1. Addition 1 is type int and has two integer #include ciostream parameters a and b 3. using namespace std; Line 8 declares an int variable 4. he functions prot declares the function z used to store the value 5. nt addition (int a,int b: addition returns nt main Line 10 calls the function passing two values 5 & 3 nt Z Line 15 is the function header it his scal the function has a header type (int) and addition (5,3: declares two int variables a & b 11. cout cc "The result is cc z; return 0; to receive the values passed to 13. 14. Laddition function Line 18 adds the values in a & 15. lint addition int int bl b together and stores them in 16. variable r Line 19 returns the value r to and stores it in variable z in 19, Lreturn ne 10 20. Copy and run the code at the right Programming Logic and Design, Seventh Edition Communication between modules The main function begins by declaring the variable z of type int. the nunctiona prototype declares the rusetion Next a call to a function addition. There is a the similarity between the structure of the call to the function ia calaing the rusetion and the declaration of the function itself int addition (int,a, int b); //parameters z addition 5, 3) llarguments We called addition passing two Previous Next Courses Calendar Notifications MessagesExplanation / Answer
Answering the addition2.cpp as nothing need to be explained in addition1.cpp.
addition2.cpp solution is as follow->
#include<iostream>
using namespace std;
int addition(int a,int b);
void print(int c );
int main()
{
int z;
z=addition(5,3);
//Replacing output line in main with user defined print() function
print (z);
return 0;
}
int addition(int a,int b)
{
int r;
r=a+b;
return (r);
}
//print function
void print(int c)
{
cout<<"The result is "<<c;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.