(Modify) Rewrite the following programs to conform to good
a. #include
int main(
){
cout <<
“The time has come”
; return 0;}
b. #include
using namespace std;
int main
( ){cout << “Newark is a city\n”;cout <<
“in New Jersey\n”; cout <<
“It is also a city\n”
; cout << “in Delaware\n”
; return 0;}
c. #include
using namespace std;
int main() {cout << Reading a program\n”;cout <<
“is much easier\n”
; cout << “if a standard form for main is used\n”
; cout
<<“and each statement is written\n”;cout
<< “on a line by itself\n”
; return 0;}
d. #include
using namespace std;
int main
( ){ cout << “Every C++ program”
; cout
<<“\nmust have one and only one”
;
cout << “main function”
;
cout <<
“\n The escape sequence of characters”)
; cout <<
“\nfor a newline can be placed anywhere”
; cout
<<“\n in the message passed to cout”
; return 0;}
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
C++ for Engineers and Scientists
- State which of the following are true and which are false. If false, explain your answer.c) The statement printf("a = 5;"); is a typical example of an assignment statementarrow_forward(General math) The volume of oil stored in an underground 200-foot deep cylindrical tank is determined by measuring the distance from the top of the tank to the surface of the oil. Knowing this distance and the radius of the tank, the volume of oil in the tank can be determined by using this formula: volume=radius2(200distance) Using this information, write, compile, and run a C++ program that accepts the radius and distance measurements, calculates the volume of oil in the tank, and displays the two input values and the calculated volume. Verify the results of your program by doing a hand calculation using the following test data: radius=10feetanddistance=12feet.arrow_forwardHow should I answer the following regarding the first main function?arrow_forward
- State whether the following are true or false. If the answer is false, explain why.d) An expression containing the || operator is true if either or both of its operands is true. .arrow_forwardFor each of the following statements, state whether it is True or False.arrow_forwardProblem 1 (#2.1.8). Determine whether these statements are true or false. a) ∅ ∈ {∅} b) ∅ ∈ {∅,{∅}} c) {∅} ∈ {∅} d) {∅} ∈ {{∅}} e) {∅} ⊂ {∅,{∅}} f) {{∅}} ⊂ {∅,{∅}} g) {{∅}} ⊂ {{∅},{∅}}arrow_forward
- (Physics) a. The weight of an object on Earth is a measurement of the downward force onth e object caused by Earth’s gravity. The formula for this force is determined by using Newton’s Second Law: F=MAeFistheobjectsweight.Mistheobjectsmass.AeistheaccelerationcausedbyEarthsgravity( 32.2ft/se c 2 =9.82m/ s 2 ). Given this information, design, write, compile, and run a C++ program to calculate the weight in lbf of a person having a mass of 4 lbm. Verify the result produced by your program with a hand calculation. b. After verifying that your program is working correctly, use it to determine the weight, on Earth, of a person having a mass of 3.2 lbm.arrow_forwardFill in the blanks (using C programming) that gives the binary system numbers of the input. The output order should be as given and you are not able to change the code inside void decimalToBinary() and int main().arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning