remove void?

I tried to do this without void, seem to give error. Is it possible to not use void?

Reason is, the int number has no use if I didn't give it anything to do.

Could I try and use this?

 
std::cout << number;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

int get_input_from_user()
{
    std::cout << "Please give us one integer: ";
    int x{};
    std::cin >> x;

    return x;
}

int multiply_number(int number_input)
{
    return number_input * 2;
}

void print_input(int y)
{
    std:: cout << "Your number multiply by two is: " << y;
}
int main()
{
    int number{multiply_number(get_input_from_user())};

    print_input(number);

    return 0;
}
Last edited on
Wow nevermind, after few attempt I solved it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

int get_input_from_user()
{
    std::cout << "Please give us one integer: ";
    int x{};
    std::cin >> x;

    return x;
}

int multiply_number(int number_input)
{
    return number_input * 2;
}

void print_input(int y)
{
    std:: cout << "Your number multiply by two is: " << y;
}
int main()
{
    int number{multiply_number(get_input_from_user())};

    print_input(number);

    return 0;
}


that OR

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

int get_input_from_user()
{
    std::cout << "Please give us one integer: ";
    int x{};
    std::cin >> x;

    return x;
}

int multiply_number(int number_input)
{
    return number_input * 2;
}

int main()
{
    int number{multiply_number(get_input_from_user())};

    std::cout << number;

    return 0;
}
Last edited on
Topic archived. No new replies allowed.