Concept explainers
Explanation of Solution
double conversion = 2.5; //Line 1
The above declaration is a correct one as the variable is correctly declared and initialized with a floating-point number.
char grade = 'B+'; //Line 2
The above declaration is incorrect as a char type variable is just a single character, whereas here we have two characters, B and +. Hence, it should be declared as a string type. The correct declaration would be:
string grade = "B+";
double 28.5 = num //Line 3
The above declaration is incorrect as the declaration does not end with a semi-colon. The correct one would be:
double 28.5 = num;
string message = ''First C++ course'; //Line 4
The above declaration is incorrect as the value must be within double quotes...
Trending nowThis is a popular solution!
Chapter 2 Solutions
C++ Programming: From Problem Analysis to Program Design
- Function #2: largest Parameters: num1 - a floating point number being compared against num2 and num3 num2 - a floating point number being compared against num1 and num3 num3 - a floating point number being compared against num1 and num2 Description: Write a function that takes in three numbers as parameters and prints out the largest of the three. If two or all of the numbers are equal, or even all three, then just print the value once. Test Cases: >>>largest(433.1, 2340.32, 12323.7) 12323.7 >>>largest(12.0, 32.1, 32.1) 32.1 >>>largest(23.44, 23.44, 23.44) 23.44arrow_forwardPlease solve this question no. 18 also. FromD.s Malikarrow_forwardFunctions and Optionals - How do I do this practice exercise using Swift code?arrow_forward
- in C language pleasearrow_forwardAdmission Write a C++ program that: Define a void function named Admission() with two parameters. The function accepts two arguments: a student’s high school grade point average (for example, GPA is 3.2) and an admission test score (for example, 83). The function then displays a message “Accepted” if the student has any of the following: A GPA of 3.6 or above and an admission test score of at least 60. A GPA of 3.0 or above and an admission test score of at least 70. A GPA of 2.6 or above and an admission test score of at least 80. A GPA of 2.0 or above and an admission test score of at least 90. If the student does not meet any of the qualifications, the function should display a message “Rejected”. //for example, here is the function header: void admission (double gpa, int score) Write a function prototype statement for function Admission before the main function, and add function definition after the main function in the program. In the main function, prompts user to enter a…arrow_forwardn. The memory for a static variable remains allocated betv Determine the value of each of the following expressions static_cast (toupper ('$')) a. b. static_cast (toupper ('3')) static_cast (toupper('#')) C. d. static cast (toupper ('d')) static cast (tolower('+')) e. f. static cast (tolower ('? ')) g. static cast (tolower ('H')) static_cast (tolower ('%') ) Determine the value of each of the following expressions: h. a. abs (12) b. fabs (23.45) c. fabs (-7.8) d. e. pow (4. g.arrow_forward
- 38. To pass a scalar variable by reference in C++, you need to include the ____ operator before the formal parameter’s name in the receiving function’s header. a. & c. $ b. * d. @ 42. A simple, or ____ variable, is one that is unrelated to any other variable in memory. a. scalar b. vector c. independent d. dependent 43. You may use an assignment statement or the ____ operator to enter data into an array element. a. comparison b. arithmetic c. extraction d. insertion 44. Each of the ____ (variables) in an array has the same data type. a.elements b.objects c.structures d.subscriptsarrow_forwardt/f?arrow_forwardComplete the following program When a machine reads blood pressure from a human body it displays two numbers they are called Systolicand Diastolic pressures. The program will take systolic and diastolic reading as input from the user and displays a message whether the person's blood pressure is "Normal" or "Elevated" or "High Blood Pressure". Program consists of two functions as follows. void input( .): This function is with two pass by reference parameters, and it reads input from the user. string process..): It receives two numbers(systolic and diastolic) and then it determines and returns a category according to the table below. Systolic |80 to 120 | 120 to 139 High blood equal and above 140 Diastolic Category Normal and 60 to 80 Elevated and 80 to 90 pressure above 90 or main () program is given below and you are asked to write the function definitions in the space provided below. #include #include using namespace std; void input(int &, int &); string process(int, int); int main()…arrow_forward
- True/False 7. Python functions can never modify a parameterarrow_forwardC++arrow_forwardWhich of the following is a correct and complete function definition? a. double funct(double x) { return 2*x; } b. double funct(Int x) { return (x-3); } c. int funct (x) { return (++x); } d. int funct (int x); e. void funct(x=7) { return 8; } f. void funct(int x=7) { return x/3; }arrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,