+ 5

Please help me out in this code.

Why am I getting a output even after writing "int" insted of "void"? https://code.sololearn.com/c2b0amuyLGPa/?ref=app

10th Jun 2018, 10:10 AM
Pratik Patil
Pratik Patil - avatar
4 Answers
+ 4
Pratik Patil Void functions are created and used just like value-returning functions except they do not return a value after the function executes. Same are the int functions . You can use as many cout you want. That's why it is getting output. It is only return type not cout type. There nothing like cout type.🙄
10th Jun 2018, 11:13 AM
Akash Pal
Akash Pal - avatar
+ 4
because your function's output is not a void, it is an int!
10th Jun 2018, 10:25 AM
Abolfazl Kashi
Abolfazl Kashi - avatar
+ 3
This is because it is only the return type if you will try to return a value it will not return it with void. Because void doesn't return anything. You using cout not return.
10th Jun 2018, 10:57 AM
Akash Pal
Akash Pal - avatar
+ 3
I am getting output even after writting void
10th Jun 2018, 11:04 AM
Pratik Patil
Pratik Patil - avatar