C++ Assignment

Submit three complete C++ files:

1. Consider the following program segment //include statement(s)

//using namespace statement

int main() {

//variable declaration

//executable statements

//return statement

}
a. Write a C++ statement that includes the header file iostream.

b. Write a C++ statement that allows you to use cin, cout, and endl

c.  without the prefix std::. Write C++ statement(s) that declare the following variables: num1,
num2, num3, and average of type int.

d. Write C++ statements that store 125 into num1, 28 into num2, and
-25 into num3.

e. Write a C++ statement that stores the average of num1, num2, and
num3, into average.

f. Write C++ statement(s) that output the values of num1, num2, num3,
and average.

g. Compile and run your program.

*********************************************************************************************************************************************

2. Consider the following C++ program in which the statements are in the incorrect order. Rearrange the statements so that it prompts the user to input the radius of a circle and outputs the area and circumference of the circle.

#include <iostream> {

int main()

cout << “Enter the radius: “;

cin >> radius; cout << endl;

double radius; double area;

using namespace std;

return 0;

cout << “Area = ” << area << endl;

area = PI * radius * radius;

circumference = 2 * PI * radius;

cout << “Circumference = ” << circumference << endl;

const double PI = 3.14;

double circumference;

}

****************************************************************************************************************

3. Consider the following program segment: //include statement(s)
//using namespace statement
int main() {

//variable declaration

//executable statements

//return statement

}
a.    Write C++ statements that include the header files iostream and string.
b.    Write a C++ statement that allows you to use cin, cout, and endl without the prefix std::.
c.    Write C++ statements that declare the following variables: name of type string and studyHours of type double.
d.    Write C++ statements that prompt and input a string into name and a double value into studyHours.
e.    Write a C++ statement that outputs the values of name and studyHours with the appropriate text. For example, if the value of name is “Donald” and the value of studyHours is 4.5, the output is:
Hello, Donald! on Saturday, you need to study 4.5 hours for the exam.
f.    Compile and run your program

Order from us and get better grades. We are the service you have been looking for.