c++基本作业
来源:百度知道 编辑:UC知道 时间:2024/06/18 15:56:06
Give meaningful identifiers for the following variables.
(a) A variable to store the first name of a student.
(b) A variable to store the discounted price of an item.
(c) A variable to store the number of juice bottles.
(d) A variable to store the number of miles traveled.
(e) A variable to store the highest test score.
5. 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.
(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 num1, num2, num3, and average of type int.
(d) Write C++ statements that store 125 into num1
(a) A variable to store the first name of a student.
(b) A variable to store the discounted price of an item.
(c) A variable to store the number of juice bottles.
(d) A variable to store the number of miles traveled.
(e) A variable to store the highest test score.
5. 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.
(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 num1, num2, num3, and average of type int.
(d) Write C++ statements that store 125 into num1
4.
a. string FirstName
b. double DiscountPrice
c. int BottleCount
d. int TracedMiles
e. int HighestScore
5.
a. #include <iostream>
b. using namespace std;
c. int num1;
int num2;
int num3
int average;
d. num1 = 125;
num2 = 28;
num3 = -25;
e. average = (num1 + num2 + num3) / 3;
f. cout << "num1:" << num1 << \n"num2:"
<< num2 << "\nnum3:" << num3 <<"\navarege:" << avarege << endl;