+1 vote
by
The task is to write a program exactly through a function, but when you return a value along with a number, it outputs 0 because of return. Is there any way to fix this?
#include <iostream>
#include "header.h"
using namespace std;

int main()
{
setlocale(LC_ALL, "russian");
int digit = 0;
cout << NumNewline(digit);
return 0;
}

int NumNewline(int num)
{
cout << "Введите число: ";
cin >> num;
while (num)
{
cout << num % 10 << endl;
num /= 10;
}
return 0;
}

1 Answer

+3 votes
by
cout << NumNewline(digit);
Why is there a cout?

return 0;
Why is there a return?
by
Michael ,
And I didn't ask to answer my question with a question.

So show me how to do it, since you are such a genius.

I can answer questions that way too, it doesn't take much intelligence


Nobody owes you anything here. If you don't understand what you copied yourself, then learn the language.
by
datka I didn't copy it, I wrote it myself. This is the first. Second - the section is called Q & A, and even the dumb person will understand that if you ask a question, you need to answer specifically, and not tease, answering questions. And I don't need to be flubbed and advice from a dilettante about what I need to learn.
by
Alexei Ukolov As expected of a short-sighted man, it's all about personalities. The dialogue is over.
by
Alexei Ukolov I don't notice, by the way, that you knew the answers in the first place. It's more like you answer every question with the hope that someone will mark it as a solution. If I asked a question, I want an answer, not a riddle that you think I should solve.
by
although all functions need to return something (except void). You didn't write that I should have used void instead of int.
although all functions need to return something (except void). You didn't write that I should have used void instead of int.

It is inconspicuous, by the way, that you knew the answers in the first place. It's more like you answer each question with the hope that someone will mark it as a solution.
Losers :)
Losers :)
...