Computer Science, asked by swarnimaa, 3 months ago

A five digit integer is given. Write a program in C++ to find sum of individual digits. If given
number is 16785 then required sum is 1 + 6 + 7 + 8 + 5 = 27​

Answers

Answered by dsoph
0

Answer:

hmm.. i haven't tapped into c++ for a while now but if i remember it right, it will go something like this:

Explanation:

int array[5] = {1, 6, 7, 8, 5};

int sum = array[0] + array[1] + array[2] + array[3] + array[4]; //this should work right?

cout << " add whatever text u want lol " << sum << " . \n ";

Similar questions