Appendix
About
This section is included to assist the students to perform the activities in the book. It includes detailed steps that are to be performed by the students to achieve the objectives of the activities.
Lesson 1: Getting Started
Activity 1: Find the Factors of 7 between 1 and 100 Using a while Loop
- Import all the required header files before the main function:
#include <iostream>
- Inside the main function, create a variable i of type unsigned, and initialize its value as 1:
unsigned i = 1;
- Now, use the while loop adding the logic where the value of i should be less than 100:
while ( i < 100){ }
- In the scope of the while loop, use the if statement with the following logic:
if (i%7 == 0) {
std::cout << i << std::endl;
}
- Increase ...
Get C++ Fundamentals now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.