C Programming - Variable Number of Arguments - Discussion
Discussion Forum : Variable Number of Arguments - Find Output of Program (Q.No. 1)
1.
What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void fun(char *msg, ...);
int main()
{
fun("IndiaBIX", 1, 4, 7, 11, 0);
return 0;
}
void fun(char *msg, ...)
{
va_list ptr;
int num;
va_start(ptr, msg);
num = va_arg(ptr, int);
num = va_arg(ptr, int);
printf("%d", num);
}
Discussion:
34 comments Page 4 of 4.
Virat said:
1 decade ago
Please explain this question.
Onkar tiwari said:
1 decade ago
If anyone can explain then please explain. I will grateful to you.
Riya said:
1 decade ago
can anyone explain this please......
Praveen said:
1 decade ago
Sir I think va_start (ptr, msg) should hold 6.
And num must return 6. ?
Give me region how it work.
And num must return 6. ?
Give me region how it work.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers