# c functions

1 vote
123 views
#include <stdio.h>
void demo()
{
printf("GeeksQuiz ");
}
int main()
{
demo();
return 0;
}
******************************************************************************
#include <stdio.h>

int main()
{
demo();
return 0;
}

void demo()
{
printf("GeeksQuiz ");

} 

will both program same  result?

edited

yes both are same,

it start the execuation o main function
0
does any one going to give error ?

I am having problem because there is no prototyping in one of them and there is no error  . I hope u understand my concern..
0
second program, have to give compilation error due to demo() doesn't declare before it's calling.

some of the compilers ( but not all ), by default assign int as return type but your original definition have void as return type., in this case also, it produce compilation error.
0
but it didn't went that way that's why I posted this question  i checked on ideone.com
0

don't trust online compilers !

check in this online compiler https://www.jdoodle.com/c-online-compiler

0

at the end we need to define function before main() if we are writing the function after main ()

is it so?

0
yes

NO.

If you want to define demo(); after main(), then you need to include the function definition before the main function, otherwise your code will result in an error.

#include <stdio.h>

void demo(); // function defination

int main() {
demo();
return 0;
}

void demo() {
printf("GeeksQuiz ");

}

## Related questions

1
204 views
How can we identify whether a function is call by value or call by refrence?? by looking at the defination or by looking at the statement where it is called. please someone explain
1 vote