C Programming - Variable Number of Arguments - Discussion
Discussion Forum : Variable Number of Arguments - Point Out Errors (Q.No. 1)
1.
Point out the error in the following program.
#include<stdio.h>
#include<stdarg.h>
fun(...);
int main()
{
fun(3, 7, -11.2, 0.66);
return 0;
}
fun(...)
{
va_list ptr;
int num;
va_start(ptr, n);
num = va_arg(ptr, int);
printf("%d", num);
}
Answer: Option
Explanation:
There is no fixed argument in the definition fun()
Discussion:
8 comments Page 1 of 1.
Swapna said:
1 decade ago
The called function should contain atleast 1 fixed argument
i.e fun( int num,...){ }
i.e fun( int num,...){ }
Vishal said:
9 years ago
If we do not supply return type in c then the default return must be int in C.
Sushmitha said:
7 years ago
Why can't we declare the variable argument in the function?
Ishaan said:
10 years ago
Isn't the return type mentioning compulsory?
Vishu said:
9 years ago
Yes, you are right @vishal.
Sathya.s said:
9 years ago
Please, explain me clearly.
Sathya.s said:
9 years ago
Please, explain me clearly.
Balu said:
1 decade ago
Please explain me.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers