a)
To prove whether the given statement is true or false.
a)
The given statement is True.
Explanation of Solution
Explanation:
The flow of control in
In procedural programming, the flow of control is same as the sequence in which the instructions and statements are written.
But in an object-oriented programming language, the flow of control differs due to function calls.
Conclusion:
Hence, in object-oriented programming paradigm also, the flow of control indicates the order in which statements execute in a program.
b)
To prove that the given statement is true or false.
b)
The given statement is False.
Explanation of Solution
Explanation:
The equality operator in C++ comprises of two equal symbols, that is, ==. The equality operator is used together with if statement in order to verify whether the values of two variables are equal or not.
The single equal symbol, =, is called the assignment operator which is used to assign values to variables.
Conclusion:
Hence, the given statement is False.
c)
To prove that the given statement is true or false.
c)
The given statement is False.
Explanation of Solution
Explanation:
When an if statement is written, the expression is written inside a pair of round brackets that does not ends with a semicolon. Whereas if the semicolon is placed after the expression in the if statement, it will not generate an expected result. Ending an if statement with a semicolon means ending the condition. It will check the condition but will end it in the same line and the logic will not be applied to the further statements.
Conclusion:
Hence, the given statement is False.
(d)
To prove that the given statement is true or false.
(d)
The given statement is False.
Explanation of Solution
Explanation:
An if statement should have a corresponding else or not is decided by the requirements of the program. If the program requires, then every if statement will have a corresponding else statement. Otherwise, if the program does not require, the if statement will not have a corresponding else part.
Whether an if statement will have a corresponding else part or not, is only decided by the program requirements and is not mandatory. A program will execute properly if only an if statement is written.
Conclusion:
Hence, the given statement is False.
(e)
To prove whether the given statement is true or false.
(e)
The given statement is False.
Explanation of Solution
Given statement:
The expression in the if statement:
if(score=30)
grade = ‘A’;
Explanation:
The expression inside the if statement assigns the variable score with a value of 30. The assignment statement is always True. Hence, in all the scenarios, the if statement will always evaluate to True and the grade variable will be assigned value ‘A’.
Conclusion:
Thus, the given statement is True.
(f)
To prove whether the given statement is true or false.
(f)
The given statement is True.
Explanation of Solution
Given statement:
The expression:
if(ch>=’A’ && ch<=’Z’)
Explanation:
The given if statement contains two conditions that are combined by “&&” operator. That is, when both the conditions are satisfied only then the if statement will evaluate to True.
For input ch<’A’, the first condition is not satisfied hence the if statement evaluates to False.
For input ch>=’Z’, both the conditions are satisfied only and only if ch=’Z’ but not for ch>’Z’.
Thus, for either of the inputs, the if statement evaluates to False.
Conclusion:
Hence, the given statement is True.
g)
To prove whether the given statement is true or false.
g)
The given statement is True.
Explanation of Solution
Given statement:
The given code is as follows.
cin >> num; if(num > 5) cout << num; num=0; else cout << “Num is zero” << endl;
Explanation:
In the given code, the if statement will be executed only when the input is greater than 5, otherwise the else statement will be executed.
The input for the given code is 5. Since the input is not greater than 5, the if statement will not be executed.
Here, for the input of 5, the else statement will be executed, and the output will be “Num is zero”.
Conclusion:
Hence, the given statement is True.
(h)
To prove whether the given statement is true or false.
(h)
The given statement is True.
Explanation of Solution
Explanation:
The result of a logical expression is either True or False. That is, a logical expression will always give a Boolean result.
A Boolean value can only be assigned to a Boolean variable but not to an int variable.
Conclusion:
Hence, the given statement is True.
(i)
To prove whether the given statement is true or false.
(i)
The given statement is True.
Explanation of Solution
Explanation:
The given expression is a combination of two statements. The first statement is x>0 which checks if the value of x is greater than 0. The second statement is “!” which inverts the result of the expression, x>0. It means that the “!” operator makes the expression as x<0.
Hence, the expression, x<0, can only be true for negative numbers.
Conclusion:
Thus, the given statement is True.
(j)
To prove whether the given statement is true or false.
(j)
The given statement is False.
Explanation of Solution
Explanation:
In C++, there are three logical operators. They are “&&”or AND operator, “||” or OR operator, and “!” or NOT operator.
The “!” operator is a logical operator.
The “!=” operator is an equality operator since it checks if one value is not equal to another value.
Conclusion:
Hence, the given statement is False.
(k)
To prove whether the given statement is true or false.
(k)
The given statement is True.
Explanation of Solution
Explanation:
In C++, there are four types of simple data types. They are integer, float, string, and boolean.
The expression in the switch statement is usually a variable. A variable can have any one of the simple data types.
In some cases when the switch contains an expression, the result of the expression can only evaluate to a value of the simple data type.
Conclusion:
Hence, the given statement is True.
Want to see more full solutions like this?
Chapter 4 Solutions
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
- Please answer in matlab code.arrow_forwardCOMPUTER AND INFORMATION SCIENCES INTRODUCTION TO PROGRAMMING ASSIGNMENT 1 The salary scales of workers in an institution are taken as input. The workers get paid as per the following rules: Scale 1: Salary is 10,000 KES. Scale 2: Salary is 15,000 KES. Scale 3: Salary is 20,000 KES. Using appropriate control structure, write a program to display salary at different scales. 2 Write a program to calculate the salary as per the following table: Years of Service Qualifications Salary <10 Post-Graduate 15000 10 Graduate 10000 <10 Post-Graduate 10000 10 Graduate 7000 3 State and explain primary Data types used in C programmingarrow_forwardQ1. Solve problem using 5-steps of Engineering Problem Solving Methodology (including algorithm) Q2. Draw flowchart diagram Q3. Write c++ program Problem Statement:An election is a formal group decision-making process by which a population chooses a candidate by castingvotes. Each candidate is assigned name and a specific symbol. A ballot paper is used to cast the vote. Eachballot paper contains symbols of the candidate. A person can vote a candidate by stamping on a specific symbol.The ballot paper should be considered as a spoilt ballot if a person does not stamp or stamp on more than onesymbol. Finally ballot paper has to be dropped in a ballot box.Write a C++ program that reads the information from the user to enter the name of the candidate, the totalnumber of received votes, and the spoilt votes in a local election. The total number of participants (candidates)are 5. If the user mistakenly enters any negative value, the program should consider that value as a positiveinteger.…arrow_forward
- Note: C++ language Write a program that determines the price of an item after discount according to the following rule: if the original price is greater than 100.00 then the discount is 10%, otherwise the discount is 7% in Summer seasons and 5% in Winter seasons. The program should read: 1- the original price of an item and 2- the current season (s for Summer, p for Spring, f for Fall and w for Winter) and prints on the screen the price after the discount.arrow_forwardSolve Allarrow_forwardCorrect and detailed answer will be Upvoted else downvoted Write a C program to check whether the number is EVEN or ODD, without using any arithmetic or relational operators.arrow_forward
- (Data processing) Years that are evenly divisible by 400 or are evenly divisible by 4 but not by 100 are leap years. For example, because 1600 is evenly divisible by 400, 1600 was a leap year. Similarly, because 1988 is evenly divisible by 4 but not by 100, it was also a leap year. Using this information, write a C++ program that accepts the year as user input, determines whether the year is a leap year, and displays a message telling the user whether the entered year is or is not a leap year.arrow_forward25. Repeat Programming Exercise 24, but the wire is to be bent in the form of a circle. In this case, the user specifies the length of the wire and the program outputs the radius and area of the circle. (You may assume that . Also declare it as a named constant.)arrow_forward(Conversion) a. Write a C++ program to convert meters to feet. The program should request the starting meter value, the number of conversions to be made, and the increment between metric values. The display should have appropriate headings and list the meters and the corresponding feet value. If the number of iterations is greater than 10, have your program substitute a default increment of 10. Use the relationship that 1 meter = 3.281 feet. b. Run the program written in Exercise 6a on a computer. Verify that your program begins at the correct starting meter value and contains the exact number of conversions specified in your input data. c. Modify the program written in Exercise 6a to request the starting meter value, the ending meter value, and the increment. Instead of the condition checking for a fixed count, the condition checks for the ending meter value. If the number of iterations is greater than 20, have your program substitute a default increment of (ending value - starting value) / 19.arrow_forward
- (Physics) Coulomb’s Law states that the force, F, acting between two electrically charged spheres is given by this formula: F=kq1q2r2 q1isthechargeonthefirstsphere.q2isthechargeonthesecondsphere.risthedistancebetweenthecentersofthetwospheres.kisaproportionalityconstant. Write an assignment statement to calculate the force, F.arrow_forward(Conversion) Write a C++ program that converts gallons to liters. The program should display gallons from 10 to 20 in 1-gallon increments and the corresponding liter equivalents. Use the relationship that 1gallon=3.785liters.arrow_forwardAn initial block statement can no longer be used after a certain point in time has passed.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT