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

  Write a class coord that includes degrees and minutes

The main () program must allow the user to enter the coordinates one-by-one, create the Coord object, and apply its toString() method for displaying. You can use hex character constant 'xB0' for printing the degree symbol (°).

  Write a program to make the ssds function

Write a program to make the SSDs function as a MM:SS real-time clock. Hint: You must not use a single delay routine for the one second delay because that will not allow for persistence of vision. The displays need to be constantly refreshed during ev..

  Create a class account that stores customer name account

Create a class account that stores customer name, account number and type of account. From this derive class es curr_acct and sav_acct to make them more specific to their requirements. Include necessary member functions in order to achieve the follow..

  Write code that declares an int array named month

Write code that declares an int array named month with 5 rows and 7 coloumns and initializes every element to -1.

  Write a reservation system for an airline flight

Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row. Use a two dimensional array of strings to maintain a seating chart. In addition create a array to be used as a waiting list in case the pla..

  The program will read integers values

Write a C++ program to do the following. The program will read integers values one at a time from standard input (cin) until you read the value 150. assume that the number of values read in is at least 1 and less than or equal to 100

  Compose a c++ program that print the given output

Compose a C++ program that will contain -Calculate the output of the three car positions for a two lap race and three lap race, using user input for all three cars lap times, and using variables for storing the data for each car.

  Write a program that converts between app and ppm values

Write a simple program that converts between APP and PPM values

  Write program function prompt user for number of elements

Write a C++ program main function which will prompt the user for the number of elements called N desired for an array which has the capacity to store 50 elements.

  Calculate the celsius equivalent of a fahrenheit temperature

Construct a program that allows you to calculate the Celsius equivalent of a Fahrenheit temperature.

  Program that read in from the key board a string

Write a complete C++ program that read in from the key board a string and convert all letters in the string to upper cases. You are not allowed to use toupper function.

  Write a program in c++ to accept a string

Write a program in C++ to accept a String and print the total no of vowels in it. Also print the string in upper and lower case

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