Answer the question
In order to leave comments, you need to log in
What is return for?
I may be an incredibly stupid person (although I don’t consider myself one), but for the life of me I can’t understand what the record “return 0”, “return *some variable*”, etc. does.
I watch a video tutorial and there a person wrote this code
#include <stdio.h>
void print (float number){
printf ("Your number is %.2f\n", number);
}
float del (float a, float b){
float res;
if (b != 0)
res = a / b;
else
res = 0;
return res;
}
int main (){
int num1, num2;
scanf ("%d", &num1);
scanf ("%d", &num2);
float result = del (num1, num2);
print (result);
return 0;
}
Answer the question
In order to leave comments, you need to log in
but all you need to know is English level 5 class, return means to return, it’s easy to guess that this construction indicates what exactly the function will return as a result of its work, and * res * there or 0 does not matter: in the case of C + + the main thing is that the compiler approves this value for compliance with the specified return type
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question