+ 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

13th Aug 2018, 1:08 AM
Nihilistic Depths
Nihilistic Depths - avatar
2 Respostas
+ 3
// this function returns an int int my_func1() { return 0; } // this function returns nothing void my_func2() { cout << "0"; }
13th Aug 2018, 1:23 AM
Eduardo Petry
Eduardo Petry - avatar
+ 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☺️☺️.
13th Aug 2018, 4:51 AM
Meet Mehta
Meet Mehta - avatar