C Programming - Variable Number of Arguments - Discussion

Discussion Forum : Variable Number of Arguments - Find Output of Program (Q.No. 3)
3.
What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void dumplist(int, ...);

int main()
{
    dumplist(2, 4, 8);
    dumplist(3, 6, 9, 7);
    return 0;
}
void dumplist(int n, ...)
{
    va_list p; int i;
    va_start(p, n);

    while(n-->0)
    {
        i = va_arg(p, int);
        printf("%d", i);
    }
    va_end(p);
    printf("\n");
}
2 4
3 6
2 4 8
3, 6, 9, 7
4 8
6 9 7
1 1 1
1 1 1 1
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
20 comments Page 2 of 2.

Harini said:   1 decade ago
Actually n-->0 means that,

n-- > 0 i.e. n is first decremented and is compared with 0.

Niyati said:   1 decade ago
Please can anyone clearly explain this problem.I am not able to understand this.please..

Priya said:   1 decade ago
I can't understand, please anyone explain the above program clearly.

Kalpana said:   1 decade ago
I need a clear explanation about this program.

Pooja said:   2 decades ago
Please describe how to solve this problem.

Mahi said:   8 years ago
Decrement value of n.

Untill (n--) to 0.

Akshaya Shelke said:   8 years ago
Thanks for your explanation @Vvvvvvv.

K.karthik raja said:   1 decade ago
Please clearly explain this problem?

Teju said:   9 years ago
while(n-->0) Explain this line.

Sandipan said:   9 years ago
What is va_end?


Post your comments here:

Your comments will be displayed after verification.