0

Is it the same if we write int say_hello(); instead of void say_hello(); ? If not what's the difference ?

#include <stdio.h> void say_hello(); int main() { int i; for (i = 0; i < 5; i++) { say_hello(); } return 0; } void say_hello() { static int num_calls = 1; printf("Hello number %d\n", num_calls); num_calls++; }

12th Oct 2019, 2:21 PM
Sk. Ahmed Razha Khan
Sk. Ahmed Razha Khan - avatar
1 Réponse
+ 2
So void means that when you call this method nothing is returned but I guess your confused as to why somthing is being printed?? That's because the code inside the say_hello method is executed and prints directly to console and that's all, the actual method is not returning anything back to were it was called.
12th Oct 2019, 2:33 PM
D_Stark
D_Stark - avatar