Answer to Question #100842 in C++ for zahra

Question #100842
Write a program that will display all numbers multiple of 7 which are between 1 and 100 and display the cumulative sum as well as the final sum. solve with while
1
Expert's answer
2020-01-03T03:11:19-0500
#include<iostream>

using namespace std;

int main() {
	int multiple = 7;

	int max = 100 / multiple;

	int i = 0;
	int sum = 0;
	while (i < max) {
		cout << multiple * (i + 1) << " ";
		sum += multiple * (i + 1);

		i++;
	}

	cout << endl << multiple * i;
	cout << endl << sum << endl;

	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS