New course! Every coder should learn Generative AI!
Try a free lesson0
Return type
what does it means that the program doesnt return value?
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.
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;
}
0
i know but what does it means doesnt return value?
0
ok thanks you all
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.
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.