Chat with us, powered by LiveChat devry comp122 week 5 homework | Writedemy

devry comp122 week 5 homework

devry comp122 week 5 homework

Question

COMP122

Week 5 Homework

Complete the following problems.

1. Determine the value of the following expressions.

a. toupper(‘b’)

b. tolower(‘C’);

c. pow(3.0,3.0);

d. sqrt(81.0);

e. fabs(-1.23);

f. floor(22.46);

g. ceil(33.3);

2. Using the functions in the cmath library, write the following mathematical formulas as C++ expressions.

a. 3.02.4

b. (x – y)1/2 Note: the ½ power is the square root

c. |y – 42.3|

d.( -b + (b2 – 4ac)1/2) / 2a

3. Consider the following functions:

int func1(int x)

{

int r, s;

r = 2 * x;

if (r > 10)
{

s = x / 2;

}

else
{

s = x / 3;
}

return s – 2;

}

int func2(int a, int b)

{

int r, s;

s = 0;

for(r = a; r < b; r++)

{

s++;

}

return s;

}

What is the output from the following program fragments?

int a, b;

a. a = 10;
cout << func1(a) << endl;

b. a = 5; b = 12;

cout << func2(a, b) << endl;
c. a = 8;

b = func1(a);

cout << a << ” ” << b << ” ” << func2(a, b) << endl;

4. Write a C++ function that has an input of a char value and returns true if the character is lower case or false otherwise.

5. Write a C++ function that has three inputs which are integers. The function returns true if the first number raised to the power of the second number equals the third number.

6. What is a function prototype? When is it needed?

7. What is the difference between an actual parameter and a formal parameter?

8. Explain the difference between pass by value parameters and pass by reference parameters.

9. Explain the difference between function parameters, local variables, and global variables regarding the parts of a program that can access these values.

10. What does void signify when used as the return type of a function?

11. What is the output of the following program fragment:

void find(int a, int& b, int& c)
{
int temp;

c = a + b;

temp = a;

a = b;

b = 2 * temp;

}

int main()

{

int x, y, z;

x = 15;

y = 25;

z = 30;

find(x, y, z);

cout << x << ” ” << y << ” ” << z << endl;

find(y, x, z);

cout << x << ” ” << y << ” ” << z << endl;

find(z, y, x);

cout << x << ” ” << y << ” ” << z << endl;

}

12. Write a C++ function which initializes its three reference parameters. The function should take an int, double, and string parameter and initialize them to 0 and the empty string (“”).

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order