edited by
16,256 views
51 votes
51 votes

Consider the following C program:

double foo (double);		/* Line 1 */
int main() {
    double da, db;
    //input da
    db = foo(da);
}
double foo (double a) {
    return a;
}

The above code compiled without any error or warning. If Line $1$ is deleted, the above code will show:

  1. no compile warning or error

  2. some compiler-warnings not leading to unintended results

  3. some compiler-warnings due to type-mismatch eventually leading to unintended results

  4. compiler errors

edited by

8 Answers

1 votes
1 votes
D since foo is defined after main so it should be declared before main.
0 votes
0 votes
In c  if a function is called before its declaration, the compiler assumes return type of the function as int so deleting line 1 cause error.
0 votes
0 votes

GCC Compiler generated result

When the function prototype is removed Compiler would give Type mismatch error, as already answered above.

So Answer is D

Answer:

Related questions

37 votes
37 votes
4 answers
2
Kathleen asked Sep 22, 2014
23,509 views
The grammar $A \rightarrow AA \mid (A) \mid \epsilon$ is not suitable for predictive-parsing because the grammar is:ambiguousleft-recursiveright-recursivean operator-gram...
13 votes
13 votes
3 answers
4
Kathleen asked Sep 22, 2014
12,424 views
A common property of logic programming languages and functional languages is:both are procedural languages both are based on $\lambda$-calculusboth are declarativeboth us...