Write a function prototype

Assignment Help C/C++ Programming
Reference no: EM131117449

Homework

Determine the value, true or false, of each of the following Boolean expressions. Assume the following two declarations have been made:

int count = 0, limit = 10, x, y;

1. (count == 0) && (limit < 20)

2. count == 0 && limit < 20

3. (limit > 20) || (count < 5)

4. !(count == 12)

5. (count == 1) && (x < y)

6. (count < 10) || (x < y)

7. !( ((count < 10) || (x < y)) && (count >= 0) )

8. ((limit / count) > 7) || (limit < 20)

9. (limit < 20) || ((limit/count) > 7)

10. ((limit/count) > 7) && (limit < 0)

11. (limit < 0) && ((limit / count) > 7)

12. (5 && 7) + (16) (answer is true)

13.) Write an if-else statement that ouputs the word Solvent, decreases the value of savings by expenses, and sets the value of expenses to 0, provided the savings is at least as large as the expenses. If, however, savings is less than expenses, the if-else statement simply outputs the word Bankrupt and does not change the value of any variables. The variables, expenses and savings, are both float.

14.) Write an if-else statement that outputs the word Warning provided that the value of the variable temperature is greater than or equal to 100, or the value of the variable pressure is greater than or equal to 200, or both. Otherwise, the if-else statement outputs the word OK.

15.) If 0 is considered false and all other integer numbers are considered true in C++, what is the output of the following cout statements? You can assume that x is set up in the program as an integer and has a value.
a.) if (x=0)
cout << "0 is true" << endl;
else
cout << "0 is false" << endl;

b.) if (1)
cout << "1 is true" << endl;
else
cout << "1 is false" << endl;
c.) if (-1)
cout << "-1 is true" << endl;
else
cout << "-1 is false" << endl;

16.) What output will be displayed from the following code if int x = 2;
cout << "Start" << endl;
if (x <= 3)
if (x!= 0)
cout << "Hello from the second if" << endl;
else
cout << "Hello from the else" << endl;
cout << "End" << endl;
cout << "Start again" << endl;
if (x > 3)
if (x!= 0)
cout << "Hello from the second if" << endl;
else
cout << "hello from the else" << endl;
cout << "End Again" << endl;

17.) What will be displayed from the following code if extra = 2, if extra = -37, and if extra = 0?
if ( extra < 0)
cout << "Small" << endl;
else if (extra == 0)
cout << "Medium" << endl;
else
cout << "Large" << endl;

18.) What output will be displayed from the following code if x =1, if x=3, if x=2, and if x =4?
switch (x+1)
{
case 1: cout << "Roast Beef" << endl; break;
case 2: cout << "Roast Worms" << endl; break;
case 3: cout << "Chocolate ice cream" << endl;
case 4: cout << "Onion ice cream" << endl; break;
default: cout << "Bon Appetit" << endl;
}

19.) What output is produced by the following code?
a.) int x = 10;
while (x > 0)
{
cout << x << endl;
x = x - 3;
}
b.) int x = 10;
do
{
cout << x << endl;
x = x - 3;
} while (x > 0);

c.) int x = -42;
do
{
cout << x << endl;
x = x - 3;
} while (x > 0);

d.) int x = 10;
while (x > 0)
{
cout << x << endl;
x = x + 3;
}
e.) int count = 3;
while (count-- > 0)
cout << count << " ";

f. ) int count = 3;
while (--count > 0)
cout << count << " ";

g.) int n = 1;
do
{
cout << n<< " ";
} while (n++ <= 3);

h.) int n = 1;
do
{
cout << n << " ";
} while( ++n <= 3);

j.) for (int count = 1; count < 5; count ++)
cout << (2 * count) << " ";

k.) for (int n = 10; n > 0; n = n- 2)
{
cout << "Hello ";
cout << n << endl;
}

l.) for (float sample = 2; sample > 0; sample -= 0.5)
cout sample << " ";

20.) Rewrite the following loops as for loops:
a.) int i = 1;
while (i <= 10)
{
if (i < 5 && i != 2)
cout << ‘X';
i ++;
}

b.) int i = 1;
while (i <= 10)
{
cout << ‘X';
i += 3;
}

c.) int m = 100;
do
{
cout << ‘X';
m += 100;
} while (m < 1000);

21.) Code a C++ loop that will write the word "Hello" to the screen 10 times.

22.) Code a loop that will read in a list of even numbers (such as 2, -4, 8, 6) and compute the total of the numbers in the list. The list is ended with a sentinel value so you must decide what would be a good sentinel value and declare it as such before the loop.

23.) What will print as a result of the following nested loops?
for (int n = 1; n <= 3; n++)
for (int m = 5; m >= 1; m--)
cout << n << " times " << m << " = " << n*m << endl;

24.) Code two nested loops in C++ that will produce the following output:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25

25.) Write a function prototype and a function definition for a function that takes one argument of type float and returns the character value ‘P' if the argument is positive and returns ‘N' if the argument is zero or negative.
26.) Write a function definition for a function called even that takes one argument of type int and returns a bool value. The function returns true if the argument is an even number. Otherwise, it returns false.

27.) Write a function definition for a function called in_order that takes three arguments of type int and returns true if the arguments are in ascending order. Otherwise it returns false. For example, in_order(1,2,3) and in_order(1,2,2) return true. And in_order(1,3,2) returns false.

28.) What is the output produced by the following code segment?
#include <iostream>
char mystery (int,int); what is this called???
int main ()
{
cout << mystery(10,9) << "ow" << endl;
return 0;
}
char mystery (int first, int second)
{
if (first >= second)
return ‘W';
else
return ‘H';
}

Reference no: EM131117449

Questions Cloud

Write a program to compute sinx : Write a program to compute sinx for given x. The user should supply x and a positive integer n.
Competition make the project results obsolete : Projects are supposed to succeed, not fail. However, termination is an option to consider when all but which one of the following conditions exist?
Discuss four governmental expenditures that you believe : From the first e-Activity, discuss four governmental expenditures that you believe will have a significant impact on your local economy over the next year. Justify your response with examples.
Identifying competitive advantage : When identifying competitive advantage, which characteristic of a strength or weakness (value, rareness, imitability, and sustainability) is the most important in health care organizations? Explain your answer.
Write a function prototype : Determine the value, true or false, of each of the Boolean expressions - Write a function prototype and a function definition for a function.
What factors affect the future movements in the value : What factors affect the future movements in the value of the euro against the dollar?
Disadvantages of using preferred stock in capital structure : Coogly has outstanding preferred stock That pays a dividend of $4 per share and sells for $82 per share, with a floatation cost of $6 per share. What is the component cost for Coogly's preferred stock? What are the advantages and disadvantages of usi..
Analyze and forecast a comparison of the population growth : Analyze and forecast a comparison of the population growth rate from 2010 through 2016 of the State of Michigan and your state. Provide these figures in your response for each year.
The five generic marketing situations : For each of the five generic marketing situations, identify uncontrollable and controllable factors that should be considered in the development of marketing strategies.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd