Concept explainers
Why should you indent the statements in the body of a loop?
Explanation of Solution
Reason for statement indention:
Some of the reasons for “indenting C++ statements in the body of a loop” are:
- The body of a loop contains C++ statements and it gets executed once the expression is valid. Otherwise it won’t execute.
- Multiple loop statements are enclosed by braces ({}) and should be intended, because, it separates the condition statements from surrounding code.
- Hence, it helps the programmer to easily identify the statements that are conditionally-executed.
Example:
Consider the following example program contains conditionally-executed statements:
Program code:
//Include required header files
#include <iostream>
#include<iomanip>
using namespace std;
//Main function
int main()
{
//declare the variable “n” as integer set “n” as 5
int n = 5;
//loop i values for 5 times
for (int i = 1;i <= n;i++)
{
//check the number is even
if (i % 2 == 0)
{
//if so, display it
cout << "\n"<<i<<" is even";
}
}
cout << endl;
return 0;
}
The highlighted statements are indented within the loop.
2 is even
4 is even
Want to see more full solutions like this?
Chapter 5 Solutions
EBK STARTING OUT WITH C++ FROM CONTROL
Additional Engineering Textbook Solutions
Modern Database Management
SURVEY OF OPERATING SYSTEMS
Degarmo's Materials And Processes In Manufacturing
Mechanics of Materials (10th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Electric Circuits. (11th Edition)
- What are the steps you will follow in order to check the database and fix any problems with it and normalize it? Give two references with your answer.arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Consider that the database offline is not allowed since people are connected to it and personal data might be bridged and not secured. Provide three refernces with you answer.arrow_forwardShould software manufacturers should be tolerant of the practice of software piracy in third-world countries to allow these countries an opportunity to move more quickly into the information age? Why or why not?arrow_forward
- I would like to know about the features of Advanced Threat Protection (ATP), AMD-V, and domain name space (DNS).arrow_forwardPlease show the code for the Tikz figurearrow_forwardWhat is Windows Server and what is the Differences between Windows Server 2019 and the Windows Operating System that people have installed on their personal computer.arrow_forward
- solve and show the tree on paperarrow_forwardI need help to resolve the following activityarrow_forwardModern life has been impacted immensely by computers. Computers have penetrated every aspect of oursociety, either for better or for worse. From supermarket scanners calculating our shopping transactionswhile keeping store inventory; robots that handle highly specialized tasks or even simple human tasks,computers do much more than just computing. But where did all this technology come from and whereis it heading? Does the future look promising or should we worry about computers taking over theworld? Or are they just a necessary evil? Provide three references with your answer.arrow_forward
- What are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forwardYou are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forward(A) A cellular system has 12 microcells with 10 channels per cell. The microcells are split into 3 microcells, and each microcell is further split into 4 picocells. Determine the number of channels available in system after splitting into picocelles.arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning