M
M
Michael2020-10-13 14:05:54
C++ / C#
Michael, 2020-10-13 14:05:54

Is there any way to do without output 0?

The task is to write a program through a function, but when returning a value along with a number, it displays 0 due to 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;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-10-13
@alexey-m-ukolov

cout << NumNewline(digit);
Why is cout here?
return 0;
Why return here?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question