9.how do you write a function that takes a variable number
of arguments? What is the prototype of printf () function?
10.How do you access command-line arguments?
11.what does ‘#include<stdio.h>’ mean?
12.what is the difference between #include<> and #include”…”?
13.what are # pragma staments?
14.what is the most appropriate way to write a
multi-statement macro?

Answers were Sorted based on User's Feedback



9.how do you write a function that takes a variable number of arguments? What is the prototype of p..

Answer / saurabh

WHERE IS THE ANSWER MY FRIENDS?

Is This Answer Correct ?    1 Yes 0 No

9.how do you write a function that takes a variable number of arguments? What is the prototype of p..

Answer / sumati

9. By using default arguments, we can write a function that
takes a variable number of arguments.

10. By default, 2 arguments are passed to main function..
One is the count that contains number of arguments + 1.
1 is for the program name.

Second argument is the array of arguments...with prgram name
at the first index i.e. [0] and the size of array is count-1.

Is This Answer Correct ?    0 Yes 1 No

9.how do you write a function that takes a variable number of arguments? What is the prototype of p..

Answer / deesha

explained how we can utilize the operator ellipsis (…) to
pass variable number of arguments to a function. I have
utilised there the concept of pointers to access the
variable arguments. The standard C Library provides support
to access these arguments. Use for this support
All you need is to know the last argument before the
ellipsis operator(At least one argument is must to use
variable arguments), let’s call it larg

suppose

fun(type var1,type var2,...)

is a function, then larg corresponds to var2

Now we need to declare the list using va_list
i.e.,

va_list al

now initialize it using va_start

va_start(al,larg);

Now to access each argument, we must know the expected type
of the argument

type var_name = va_arg(al,type);

When we have accessed all the variable arguments, we need to
clean up

va_end(al);

Using standard library, we can easily access the variable
arguments

Is This Answer Correct ?    0 Yes 1 No

9.how do you write a function that takes a variable number of arguments? What is the prototype of p..

Answer / 2028

The above reply is an vague idea for the concept idea some
details may be with an example will be an good input from
nay one of us

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Interview Questions

main() {int i=5; // line 1 i=(++i)/(i++); // line 2 printf("%d",i); // line 3 } output is 2 but if we replace line 2 and line 3 by printf("%d",i=(++i)/(i++)); then output is 1. Why?

1 Answers   GATE,


Explain two-dimensional array.

0 Answers  


What’s the special use of UNIONS?

0 Answers   ADP,


How a string is stored in c?

0 Answers  


Explain what are compound statements?

0 Answers  






what is a static function

10 Answers   Satyam,


What is the use of printf() and scanf() functions?

0 Answers  


How can I make a program in c to print 'Hello' without using semicolon in the code?

9 Answers   C DAC, Practical Viva Questions,


main() { float f1=10.5; double db1=10.5 if(f1==db1) printf("a"); else printf("b") }

2 Answers   CSC,


What is assignment operator?

0 Answers  


write a c program to find the sum of five entered numbers using an array named number

0 Answers   TATA,


Which are low level languages?

0 Answers  


Categories