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

  Multiple choice question on c programming

Create a function to print "88 is a great port number" function name is yourName_PrintFunction no input no return type print "88 is a great port number"

  C code christmas assignment

C code Christmas assignment. We are supposed to create a record generating programme that will accept user information and output student information (student grade, highest and lowest grade, pass or fail status). Must be done in modular form,..

  Write an algorithm to compute the volume of water

Write an algorithm to compute the volume of water in cubic feet, flowing through a pipe of diameter d in feet, with a velocity of v feet per second.

  Users to input two forces by their components

write a programm to ask users to input two forces by their components of (Fx1,Fy1) and (Fx2,Fy2) from the keyboard.call twice the function to display both magnitude and direction angle of two forces on the screen.add two forces and display both magni..

  A company hired 10 temporary workers

A company hired 10 temporary workers who are paid hourly and you are given a data file that contains the last name of the employees, the number of hours each employee worked in a week, and the hourly pay rate of each employee.

  Implement a class to represent a matrix

Implement a class to represent a matrix. While doing this exercise, you are allowed only to use C++ primitive types and arrays. You may not use STL in your Matrix definition. You must use dynamic memory.

  Prepare a program to print the permutation

write a program to print the permutation that lexicographically precedes the given input permutation. If the given permutation is the lexicographically least permutation, then print the input permutation itself.

  Maturity amount after the period of deposit

Develop a program that accepts a deposit amount and period of deposit. Calculate the maturity amount after the period of deposit. The bank pays 4% interest per year for any deposits made in the bank.

  Write appropriate mutator functions that store values

A default constructor that assigns empty strings ("") to the name, department, and position member variables, and 0 to the idNumber member variable.

  Branching statements to control the flow of a program

The purpose of this exercise is to give you an opportunity to practice using cin to handle user keyboard inputs, use branching statements to control the flow of a program, and work on your C++ programming style

  Write a program for a graphics system

Write a program for a graphics system that has classes for rectangles, squares, circles and triangles. Each of these must be derived from a base class

  Given two bit strings of length n,find the bitwise and,xor

Use a computational program (C++) you have written to do the following exercises.Given two bit strings of length n (n equal or bigger 16), find the bitwise AND, bitwise XOR of these strings.

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