search
Log In
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?

 

in Programming
edited by
123 views

2 Answers

0 votes
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
0 votes

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

0 votes
1 answer
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
asked Jun 2, 2018 in Programming saif 204 views
1 vote
1 answer
2
235 views
#include <stdio.h> #include <stdarg.h> int fun(int n, ...) { int i, j = 1, val = 0; va_list p; va_start(p, n); for (; j < n; ++j) { i = va_arg(p, int); val += i; } va_end(p); return val; } int main() { printf("%d\n", fun(4, 1, 2, 3)); return 0; } will you explain the output for the program?
asked Aug 31, 2017 in Programming suneetha 235 views
0 votes
1 answer
3
441 views
/*strcpy"copy t to s; */ void strcpy(char *s, char *t) { while((*s++=*t++) !='\0'); } Can anyone explain how *s++ or *t++ is being executed. As * and ++ are unary operators here , they will have same precedence. Unary operators having ... ). So here if we take *s++ is the increment operator being executed first or the dereferencing operator?. Can anyone show the steps of executing this function.
asked May 22, 2017 in Programming Manu FG 441 views
1 vote
0 answers
4
70 views
int main() { Char *str=”Gate2017”; printf(“%d”, fun( str )); return 0; } int fun(char *P1) { Char *P2=P1; while (*++P1) return (P1-P2); } The output of the above program will be ______ Answer given is 8...pls help
asked Sep 22, 2016 in Programming Amit puri 70 views
...