1,116 views
2 2 votes
#include <stdio.h>
int yellow();
int main()
{  
    int hello();
    yellow();
    printf("%d",hello());

    return 0;
}

int yellow(){ hello();    
}

int hello()
{printf("hello hello ");
return 1;
}

HERE I DECLARED THE FUNCTION hello() within my main function but its visible outside the main function also i expected this to give me a compilation error as the hello() is called inside yellow() but hello() is not inside the scope of yellow() but it compiles fine and outputs hello hello hello hello 1 ....are local delaration of functions globally scoped in C ??

1 Answer

0 0 votes

it is giving  compiler error since  hello() was not initialized/declared before using. 

Position:
Show:

Related questions

4 4 votes
1 1 answer
1.5k
1.5k views
pC asked Aug 8, 2016
1,523 views
Consider the following code snippet#include <stdio.h main() { char a[10]; a[0] = 'a' ; abc(a); } abc( char a[]) { printf("%s",a[0]); }According to my understanding when ...
7 7 votes
2 2 answers
320
320 views
GO Classes asked Jun 29
320 views
What is the output of the following code?#include <stdio.h struct Item { int code; int price; }; void update(struct Item *p) { p->price = p->price + 20; (*p).code = (*p)....
5 5 votes
1 1 answer
207
207 views
GO Classes asked Jun 10
207 views
Is there any difference between the following declarations?extern int fun(); int fun();Both are identical No difference, except $\texttt{extern int fun();}$ is probably i...
4 4 votes
2 answers 2 answers
3.1k
3.1k views
Gangani_Son asked Dec 14, 2018
3,137 views
What is the return value of following function for 484? What does it to in general?bool fun(int n){ int sum = 0; for (int odd = 1; n sum; odd = odd+2) sum = ...