Question

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

0 0
Add a comment Improve this question Transcribed image text
Answer #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 a comment
Know the answer?
Add Answer to:
PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.doc...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ comment code Comment the following code #include <iostream> using namespace std; class Node { public:...

    C++ comment code Comment the following code #include <iostream> using namespace std; class Node { public: Node(int val); int value; Node* next; }; Node::Node(int val){ value = val; } class List { public: List(); // Uncomment the line below once you're ready List(List &other); void push_front(int value); bool pop_front(int &value); void push_back(int value); bool pop_back(int &value); int at(int index); void insert_at(int index, int value); void remove_at(int index); int size(); private: // other members you may have used Node* head; Node*...

  • Subject: Object Oriented Programming (OOP) Please kindly solve the above two questions as soon as possible...

    Subject: Object Oriented Programming (OOP) Please kindly solve the above two questions as soon as possible would be really grateful to a quick solution. would give a thumbs up. Thank you! Q3: Question # 3 [20] Will the following code compile? If it does not, state the errors. If it does compile, write the output. //Function.cpp #include <iostream> using namespace std; void printData (long i) cout<<"In long print Data "«<i<<endl; } void printData(int i) cout<<"In int printData "<<i<<endl; ) void...

  • c++ please no global varaible write a value returning function input data to dynamically allocate a...

    c++ please no global varaible write a value returning function input data to dynamically allocate a short array of size elements and store the input data entered from the disk file into array.Return the base address of the array allocated.Read the data from the text file Hello.txt and store the data in reverse order in the array.the size of the data set will be in the file size 10 and the data was 1 2 3 4 5 6 7...

  • Use C++ 1. Explain how you would correct errors in the following program to it do...

    Use C++ 1. Explain how you would correct errors in the following program to it do what it is apparently meant to do. (10 points) a. (5 points) #include <iostream> int sumOfPositives(int a, int b); int main() { std::cout << sumOfPositives(35, ,3); return 0; int sumOfPositives(int a, int b) { int sum = 0; if(a > 0 sum += a; if(b>0) sum +=b: b. (5 points) #include <iostream> int main() { std::cout << square(35); return 0; int square (int number)...

  • 1. What is wrong with the following C++ program? #include <iostream> int main() { a =...

    1. What is wrong with the following C++ program? #include <iostream> int main() { a = 4; b = 6; cout << a << "+" << b << "=" << a+b; return 0; 2. What is wrong with the following C++ program? What was its intended output? #include <iostream> using namespace std; int main() { cout << "What is larger? e pi or pi e?" << endl; double ans1 = exp(pi); double ans2 = pi exp(1.); cout << "epi is...

  • Complete the following program to count all vowels in a word. #include #include using namespace std;...

    Complete the following program to count all vowels in a word. #include #include using namespace std; int main() { string word; cin >> word; ... for (...) { string ch = word.substr(i, 1); if (ch == "a" || ch == "e" || ch == "i" || ch == "o" || ch == "u") ... } cout << "Vowels: " << count << endl; return 0; }

  • 81. The following function call doesn’t agree with its prototype:              cout << BoxVolume( 10, 5...

    81. The following function call doesn’t agree with its prototype:              cout << BoxVolume( 10, 5 );                    int BoxVolume(int length = {1}, int width = {1}, int height = {1});                                                     T__   F__                                                                     82. The following function is implemented to swap in memory the          argument-values passed to it:         void swap(int a, int b)                   {           int temp;             temp = a;             a = b;             b = temp;        ...

  • what is the output for the following code? explain the steps. /*#include <iostream> using namespace std;...

    what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...

  • Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout...

    Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT