why cant i use void instead of int | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why cant i use void instead of int

28th Jun 2016, 5:04 PM
Manu Vinayak
Manu Vinayak - avatar
14 Answers
+ 2
void doesn't require you to return a value, int does. When running a program, the value 1 means running to the operating system, 0 is to terminate and -1 is for an error. They are little queues to the OS on what to do with the programs. For example, computer plugged in to outlet would be a 1, it has power it can run. Computer unplugged would be a 0, no power it can't run. A power outage and PC on, would result on a -1, the PC did not power down appropriately, caused errors. Hope this answers your question.
1st Jul 2016, 1:22 AM
Enith Sadler
Enith Sadler - avatar
0
you can use both of them but when you use int....you should but return (0) in the end
28th Jun 2016, 5:25 PM
Ibra Light
Ibra Light - avatar
0
What do you mean exactly with that in context of cout?
29th Jun 2016, 12:50 AM
Stefan
Stefan - avatar
0
Probably bc it's an app, not a computer program. it probably just has enough content to show the current material.
29th Jun 2016, 4:18 AM
Soon Kwon
Soon Kwon - avatar
0
it depends on your compiler you can use void or int both according to the software you are working on
30th Jun 2016, 6:33 AM
himanshu pandey
himanshu pandey - avatar
0
In void main you can use only comments. In into main you are able to use numbers for various programming. Read about data types you will understand the difference.
30th Jun 2016, 10:52 AM
Nishchay M Nayak
0
void means null and int means integer type. u can use both but it depends upon the type of compiler or software u r using like code:: blocks u can use void and int but sometimes it is doesn't run the program.
30th Jun 2016, 5:14 PM
Tanya Gupta
Tanya Gupta - avatar
0
If u reTurn something integer value then must use int keyword
1st Jul 2016, 4:07 PM
Sagar Thorat
Sagar Thorat - avatar
0
yes u can write void main() but u need not to write return 0
2nd Jul 2016, 3:57 PM
Ankit
0
Its nul
3rd Jul 2016, 10:04 PM
Malcolm
0
because void don't return any value where as in does
6th Jul 2016, 2:52 PM
Disha
0
int is used when your function is receiving integer value from another function.
9th Jul 2016, 5:47 AM
Prashant
Prashant - avatar
0
if you write any simple program which has no any return value you should write void main() but for batter practice in c++ it is must
14th Jul 2016, 6:38 PM
krishna desai
- 1
then why this app doesnt support this function
29th Jun 2016, 12:24 AM
Manu Vinayak
Manu Vinayak - avatar