+ 2

When i should use void for a function?

When ishould use void for a function?.. What is its idea?

22nd Jan 2018, 10:15 PM
‎Mohammed Abdullsalam
‎Mohammed Abdullsalam - avatar
2 Answers
+ 2
When you dont want to return a value you can use void function. Here is a example for addition: void sum(int a ,int b){ int sum = 0; sum = a+b; } And then you can call the function but return function it will make easy. int sum(int a ,int b){ return a+b; } And that's all. Hope you understand!
22nd Jan 2018, 11:11 PM
Vrushabh Desai
Vrushabh Desai - avatar