+ 1
Why use "int" datatype to declare a function?
Is really counter intuitive to me the use of the keyword that define integers in a function that doesn't
2 odpowiedzi
+ 3
// this function returns an int
int my_func1() {
return 0;
}
// this function returns nothing
void my_func2() {
cout << "0";
}
+ 3
Here function named sum is returning integer value so you have to use int.
Example :
int sum(int a,int b)
{
int c = a+b;
return c;
}
int main()
{
....
...
int d = sum(1,2);
printf("%d", d);
....
...
}
You have to write what type of data function is going to return.
Hope this helps☺️☺️.