Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Good use of whitespace. #include using namespace std; int main() { int myFirstVar; // Aligned comments yield less int yetAnotherVar; // visual clutter int thirdVar;

Good use of whitespace.

#include using namespace std;

int main() {

int myFirstVar; //

Aligned comments yield less int yetAnotherVar; // visual clutter int thirdVar;

// Above blank line separates variable declarations from the rest cout << "Enter a number: "; cin >> myFirstVar; // Note >> is under <<. Less visual clutter. // Above blank line separates user input statements from the rest yetAnotherVar = myFirstVar; // Aligned = operators thirdVar = yetAnotherVar + 1; // Also notice the single-space on left and right of + and = // (except when aligning the second = with the first =) cout << "Final value is " << thirdVar << endl; // Single-space on each side of << return 0; // The above blank line separates the return from the rest.

Figure 2.3.3: Bad use of whitespace.

#include  using namespace std; int main() { int numPeople; int totalOuncesPasta; cout<<"Enter number of people: ";cin>>numPeople; totalOuncesPasta = numPeople * 3; cout << "Cook " << totalOuncesPasta << " ounces of pasta." << endl; return 0;} 

Feedback?

PARTICIPATION

ACTIVITY

2.3.2: Whitespace.

Are the specified lines of code good or bad uses of whitespace?

#include  using namespace std; int main() { int userAge; int currentDecade; int nextDecade; int nextMilestone; cout << "Enter your age: " << endl; cin >> userAge; currentDecade=userAge/10; nextDecade = currentDecade + 1; nextMilestone = nextDecade * 10; cout << "Next big birthday is at " << nextMilestone << endl; return 0; } 

1)

int nextDecade;

Good

Bad

2)

currentDecade=userAge/10;

Good

Bad

3)

nextDecade = currentDecade + 1;

Good

Bad

4)

nextMilestone = nextDecade * 10;

Good

Bad

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

5. Describe the relationship between history and identity.

Answered: 1 week ago