retagged by
1,723 views

1 Answer

5 votes
5 votes

dynamic is a function with variable number of arguments.

Here it prints only s.

So A is correct.

See below example to know how multiple arguments passed can be used.

#include <stdio.h>
#include <stdarg.h>

double average(int num,...) {

   va_list valist;
   double sum = 0.0;
   int i;

   /* initialize valist for num number of arguments */
   va_start(valist, num);

   /* access all the arguments assigned to valist */
   for (i = 0; i < num; i++) {
      sum += va_arg(valist, int);
   }
	
   /* clean memory reserved for valist */
   va_end(valist);

   return sum/num;
}

int main() {
   printf("Average of 2, 3, 4, 5 = %f\n", average(4, 2,3,4,5));
   printf("Average of 5, 10, 15 = %f\n", average(3, 5,10,15));
}

 

Average of 2, 3, 4, 5 = 3.500000
Average of 5, 10, 15 = 10.000000

Ref: https://www.tutorialspoint.com/cprogramming/c_variable_arguments.htm

Answer:

Related questions

2 votes
2 votes
2 answers
1
admin asked Mar 30, 2020
1,034 views
Output of following program#include<stdio.h int main() { int i=5; printf("%d %d %d", i++,i++,i++); return 0; }$7\:6\:5$$5\:6\:7$$7\:7\:7$Compiler Dependent
4 votes
4 votes
1 answer
2
admin asked Mar 30, 2020
2,036 views
Assume that size of an integer is $32$ bit. What is the output of following ANSI C program? #include<stdio.h struct st { int x; static int y; }; int main() { printf(%d",s...
3 votes
3 votes
2 answers
3
admin asked Mar 30, 2020
1,509 views
Output of the following program?#include<stdio.h struct st { int x; struct st next; }; int main() { struct st temp; temp.x=10; temp.next=temp; printf("%d",temp.next,x); r...