Hi, i am a really really really new to c++ (and programing overall) and im having trouble with this piece of code. The thing i want to create is:
Write a program that asks the user for a number n and prints the sum of the numbers 1 to n
Modify the previous program such that only multiples of three or five are considered in the sum, e.g. 3, 5, 6, 9, 10, 12, 15 for n=17
It just prints every number out. Thanks in advance! :)
You also aren't summing anything either, you're just incrementing a number. If i was you i'd ignore the multiple of 3 and 5 thing first and just get this working:
Write a program that asks the user for a number n and prints the sum of the numbers 1 to n
if((x/3) || (x/5)
This seems wrong. You're just saying: if (x divided by three OR x divided by 5)
You don't really have a condition there. You're just dividing some numbers.
Presumably you actually want something like if (x divides by three exactly OR x divides by 5 exactly)