Question

Include a pseudocode or flowchart of your process. Use a loop structure to write a C++...

Include a pseudocode or flowchart of your process. Use a loop structure to write a C++ program that

A) Finds and displays how many multiples of 8 there are in between 1 to 1000 .

B) Displays all the multiples of 8 between 1 ~ 1000 , separated with commas.

C) Finds and displays the sum of all the multiples of 8 in between 1 to 1000.

Homework Answers

Answer #1

Answer:

C++ code as per your requirement

1)

//header

#include <iostream>

//namespace standard

using namespace std;

//main

int main() {

//intializing the count to 0

int multiplesOfEightCount=0;

//for loop from 1 to1 1000

for(int i=1;i<=1000;i++){

//checking if i is multiple of 8

if(i%8==0){

//if yes increment the count variable

multiplesOfEightCount++;

}

}

//printing to the user

cout<<"There are "<<multiplesOfEightCount<<" of 8 in betweeen 1 to 1000"<<endl;

}

Editor:

output:

B)

Raw code:

//header

#include <iostream>

//namespace standard

using namespace std;

//main

int main() {

//for loop from 1 to1 1000

for(int i=1;i<=1000;i++){

//checking if i is multiple of 8

if(i%8==0){

cout<<i<<",";

}

}

}

editor:

output:

c)

Raw code:

//header

#include <iostream>

//namespace standard

using namespace std;

//main

int main() {

// initialzing sum as 0

int sum=0;

//for loop from 1 to1 1000

for(int i=1;i<=1000;i++){

//checking if i is multiple of 8

if(i%8==0){

sum=sum+i;

}

}

cout<<"The sum of all the multiples of 8 in between 1 to 1000: "<<sum<<endl;

}

Editor:

output:

Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.

"Please refer to the screenshot of the code to understand the indentation of the code".

Thank you! Do upvote.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
​​​​​​WRITE FLOWCHART AND PSEUDOCODE ONLY (C++) Write the flowchart and pseudocode for the following program (but...
​​​​​​WRITE FLOWCHART AND PSEUDOCODE ONLY (C++) Write the flowchart and pseudocode for the following program (but not the program itself.) In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. ( sidea2 = sideb2 + sidec2 / sideb2 = sidea2 + sidec2 / …..) The program will read three side lengths from a text file, and then print the lengths along with...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath>...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath> using namespace std; void divisors(int num); int main () {    char repeat;    int num;       while (repeat !='n')    {        cout << "Enter a number: ";        cin >> num;        divisors(num);        cout << "Continue? (y or n): ";        cin >> repeat;    }    return 0; } void divisors(int num) {   ...
In C++ Please, In the main(), below, write a program that prompts for (1) how many...
In C++ Please, In the main(), below, write a program that prompts for (1) how many values to sum, and then (2) uses a summing loop to prompt for and add up 5 numbers. #include <iostream> #include <iomanip> using namespace std; int main() { < your answer goes here> return 0; }
In this example you are allowed to use from the C standard library only functions for...
In this example you are allowed to use from the C standard library only functions for input and output (e.g. printf(), scanf()) Complete the following functions using C programming language: intQ1_for() intQ1_while() intQ1_do() To compute the sum of all numbers that are multiples of 4, between 30 and 1000, in 3 different ways: with a for loop, a while loop and a do-while loop, accordingly. After each loop print the value. Return the total sum at the end of each...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
Use C++ only. 1) Write a full program that will take a list of years and...
Use C++ only. 1) Write a full program that will take a list of years and it will check if they are leap years. As soon as the program finds the first leap year from the list, the program terminates. The program also terminates when it reads a -1. Please make use of the do . . . while loop structure and the break statement. Example of sample runs: Enter a list of years: 1841 1854 1862 1875 1879 1892...
JustPerfects.java (for Loop). In this program, you will use loops to identify perfect numbers (a number...
JustPerfects.java (for Loop). In this program, you will use loops to identify perfect numbers (a number equal to the sum of its divisors - 6 and 28 are the first two! 6 is 2 +3 + 1 and 28 is 14+7+4+2+1). Being the perfect number is quite unique. Only 4 perfect numbers exist between 1 and 10,000 and you’ve already found two! Please write a program to find the additional pair. Bonus: How many perfect numbers exist between 10,000 and...
How to write a C++ program. Additive persistence is a property of the sum of the...
How to write a C++ program. Additive persistence is a property of the sum of the digits of an integer. The sum of the digits is found, and then the summation of digits is performed creating a new sum. This process repeats until a single integer digit is reached. Consider the following example: 1. The beginning integer is 1234 2. Sum its digits is 1+2+3+4 = 10 3. The integer is now 10 4. The sum of its digits is...
In the main(), below, write a program that prompts for (1) how many values to sum,...
In the main(), below, write a program that prompts for (1) how many values to sum, and then (2) uses a summing loop to prompt for and add up 5 numbers. #include <iostream> #include <iomanip> using namespace std; int main() {     < your answer goes here> return 0; }
Problem 8.51 Part A Write Lewis structure that obeys the octet rule for OCS and assign...
Problem 8.51 Part A Write Lewis structure that obeys the octet rule for OCS and assign formal charges to each atom. Draw the molecule by placing atoms on the grid and connecting them with bonds. Include all lone pairs of electrons. Show the formal charges of all atoms in the correct structure. SubmitMy AnswersGive Up Correct Part B Assign oxidation numbers to each of the atoms O, C, S in OCS. Express your answers as an integers. Enter your answers...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT