W
W
whatislov2020-10-31 22:52:10
C++ / C#
whatislov, 2020-10-31 22:52:10

Find all numbers that are not multiples of 5 and multiples of 3 and whose sum of digits are also non-multiples of 5 and multiples of 3. C++ problem?

Good day! Can you help with the task in C++? I can't find the sum of these numbers.

#include <iostream>

using namespace std;

int main()
{
    setlocale(LC_ALL,"Russian");
    int i=1,n,sum ;
    cout <<"Введите n(максимальное число) -> ";
        cin >> n;
    while(i<=n){
        if(i%3==0 && i%5)
        {
            cout<<"Числа,которые кратны 3 и не кратны 5 -> "<<i<<endl;
        }
           i++;
    }
    return 0;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2020-11-01
@SaNNy32

In order to find the sum of the digits of a number, you need to divide this number into digits and then calculate their sum. https://stackoverflow.com/questions/3389264/how-to...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question