C | Functions | Question 6

Output of following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

#include<stdio.h>
  
void dynamic(int s, ...)
{
    printf("%d ", s);
}
  
int main()
{
    dynamic(2, 4, 6, 8);
    dynamic(3, 6, 9);
    return 0;
}

chevron_right


(A) 2 3
(B) Compiler Error
(C) 4 3
(D) 3 2


Answer: (A)

Explanation: In c three continuous dots is known as ellipsis which is variable number of arguments of function. The values to parameters are assigned one by one. Now the question is how to access other arguments. See this for details.

Quiz of this Question

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.