C++ :: Sum Of Multiples Less Than 100

May 23, 2013

What I want it to do is have the user input a number: ex. 5 and then have the code give the sum for all the multiples of 5 less than 100, so it should be equal to 950 in this example.

Anyway, I have got so far to get it to list the numbers, but I need the sum of those numbers without all the text displayed every time.

I have chosen to use the FOR, but I am wondering if I should implement WHILE loop in my coding somewhere.

Code:
#include <iostream>
using namespace std;
int addMultiples() {
// Start

[Code] ....

I want the output like this:

What multiples are we adding? 5

The sum of the multiples of 5 less than 100 are: 950

View 7 Replies


ADVERTISEMENT

C++ :: Display Matrix Of Multiples Of 4

Feb 25, 2013

Write a c++ program to display a matrix of multiples of 4 from 1 upto 30 .....

View 1 Replies View Related

C++ :: Pythagorean Triples - Natural Ones And Multiples

Aug 30, 2014

Okay, I'm hunting down Pythagorean triples. Both the natural ones, and the multiples.

What I would like, is to read in a value n, and then output every pythagorean triple for which the values <a,b,c> are less than or equal to n.

I have a working program. However, if you run this code and then compare it to the list here [URL] ....

You will notice that there are slight discrepancies. Not every multiple on that list, is found by my program. It's almost perfect, but I would like to at least understand why some are missing. My code is simple, so I will post it in its entirety.

#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n;
cout << "a*a + b*b = c*c" << endl
<< "a,b,c are all integers" << endl

[Code] ....

View 2 Replies View Related

C# :: Small Program That Will Create Multiples Of The Previous Line?

Apr 4, 2015

Im trying to do a small program that will create multiples of the previous line *2, and spit out the anwser in seperate lines (as many times as the user wants)

Example if i wrote it in a bad way

2
4
8
16
32
etc.

At this time my code looks likes this, now im planing to get my hands on the IF statment

using System;
using System.Collections.Generic;
using System.Linq;

[Code].....

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved