Return type | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Return type

what does it means that the program doesnt return value?

5th Dec 2016, 9:16 PM
Benji Bogozini
Benji Bogozini - avatar
6 Answers
+ 3
in some function, you need to get a value from it. Let's say, the function sum. int sum(int a,int b){ c=a+b; return c; } returns gives you a value. int result = sum(2,3) // then, result its 5 There are, sometimes that you don't want to return anything, because its a process void showText(string txt){ print(txt); } void function doesn't return anything.
5th Dec 2016, 9:24 PM
Nahuel
Nahuel - avatar
0
returning no value represents void. void main () { // returning nothing } If you've added int to the function then you've to return integer int main(){ // returning integer return 0; }
5th Dec 2016, 9:20 PM
Vipul Walia
Vipul Walia - avatar
0
i know but what does it means doesnt return value?
5th Dec 2016, 9:21 PM
Benji Bogozini
Benji Bogozini - avatar
0
ok thanks you all
5th Dec 2016, 9:24 PM
Benji Bogozini
Benji Bogozini - avatar
0
a function is a piece of code that you can call many times and that does something - maybe just some actions and maybe calculations. so, if you want to assign some calculation to a variable, you return the result. if you don't need it (in case if your function just prints something or changes some global variables) you may not return anything from function.
5th Dec 2016, 9:27 PM
Demeth
Demeth - avatar
0
I am not sure if you are talking about compilation error. if so it means a non void function not returning a value, that is function declaration state it will return a value but in code their is a place where it returns without returning any value.
6th Dec 2016, 2:20 AM
Balaji Kannadassan
Balaji Kannadassan - avatar