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 output of the following program? #include using namespace std; int main() int count; int alpha(51: alpha -4; for (count 1; count

Output will be:

List elements: 6 10 14 18 26

Explanation:

Initially given alpha=4;

then for count = 1;

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

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

for count = 2;

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

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

for count = 3;

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

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

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

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

Valid calls are:

a) sum(a, b, c);

output would be: c = 15

b) sum(list1,list2, c);

output would be: c = 3

because list1 = 1, list2 = 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, list2, c); means sum(2, 3, c) yields c = 5

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

Please give thumbsup, if you like it. Thanks.

Add Answer of: PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.doc...
More Homework Help Questions Additional questions in this topic.

• JAVA design a class named Rectangle to represent a rectangle. The class contains: A method named getPerimeter() that returns the perimeter. Two double data fields named width and height that specify...

Need Online Homework Help?

Get FREE EXPERT Answers
WITHIN MINUTES
Related Questions