According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments? a) main(int argc, char *argv[]) b) main(argc,argv) int argc; char *argv[]; c) main() {int argc; char *argv[]; } d) None of the above 26. What error would the following function give on compilation? f(int a, int b) { int a; a=20; return a; } a) missing parenthesis in the return statement b) The function should be declared as int f(int a, int b) c) redeclaration of a d) None of the above

This question is related to Sonata Interview

Showing Answers 1 - 4 of 4 Answers


  • May 13th, 2015


  Was this answer useful?  Yes

Kritika SK

  • Jun 12th, 2015

Answer to the first question::::
The option a is correct.
As we know the syntax of function declaration in C.It is necessary to mention the data type of parameter.otherwise by default the data type will be void and that is not what we want as argc is of integer type and argv is an array and SO option b doesnt follow the syntactical rules of functn declaration and it is incorrect.
Function declaration doesnt contain body of the function which is given in option C. So, option c is also incorrect.
Answer to the second question:::::
option c-redeclaration of a.
one of the parameters of the function is a and the local variable of the function is also a. the value of parameter will be overwritten by value of local variable.
So the error is in redeclaration of a.

  Was this answer useful?  Yes


  • Aug 8th, 2015

B, because Function return type is not declared.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions