Homework Help Question & Answers

PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.doc...

what's the solution for the c++ project?

PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.docx Question1: What is the out

Question2: Suppose that you have the following program with a user-defined function name sum. In the program the function sum

void sum(int x, int y, int & z) z=x+y; int main() int listi[3], list2[3]; int a 5, b 10,c-e; for (int i -e;i<3; i+) list1[i]

question: The following program declares an array of char named as myString There are 6 following cases (a b, cd,e,f) to acce

PART2 -Requirement Write an application for a Carpet instalation company that provides the quote for Carpet Installation. Eac

PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.docx Question1: What is the output of the following program? #include using namespace std; int main() int count; int alpha(51: alpha[0] -4; for (count 1; count
0 0
ReportAnswer #1

Answer 1:

Output will be:

List elements: 6 10 14 18 26

Explanation:

Initially given alpha[0]=4;

then for count = 1;

alpha[count]=4*count+10; //alpha[1] = 4* 1 + 10 = 14

alpha[count-1]=alpha[count]-8; //alpha[0] = alpha[1] - 8 = 14 - 8 = 6; final value of alpha[0] will be 6

for count = 2;

alpha[count]=4*count+10; //alpha[2] = 4* 2 + 10 = 18

alpha[count-1]=alpha[count]-8; //alpha[1] = alpha[2] - 8 = 18 - 8 = 10; final value of alpha[1] will be 10

for count = 3;

alpha[count]=4*count+10; //alpha[3] = 4* 3 + 10 = 22

alpha[count-1]=alpha[count]-8; //alpha[2] = alpha[3] - 8 = 22 - 8 = 14; final value of alpha[2] will be 14

Similarly we can calculate for count = 4 and count = 5 and can find alpha[3], alpha[4].

When we print the value for array alpha[5] then it will print 6 10 14 18 26

Answer 2:

Valid calls are:

a) sum(a, b, c);

output would be: c = 15

b) sum(list1[0],list2[0], c);

output would be: c = 3

because list1[0] = 1, list2[0] = 2

c) is not valid call

It would give error

error: no matching function for call to 'sum'

d)

for(int i=1; i<3; i++)

{

sum(list1[i], list2[i], c);

cout<<"c = "<<c<<endl;

}

Output would be:

c = 5

c = 7

because sum(list1[1], list2[1], c); means sum(2, 3, c) yields c = 5

and sum(list1[2], list2[2], c); means sum(3, 4, c) yields c = 7

Please give thumbsup, if you like it. Thanks.

Add Homework Help Answer
Add Answer of:
PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.doc...
Your Answer: Your Name: What's your source?
Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
More Homework Help Questions Additional questions in this topic.
Need Online Homework Help?
Ask a Question
Get FREE EXPERT Answers
WITHIN MINUTES
Related Questions