arguments are transferred through shared memory block

arguments are transferred through stack (the first argument on a list is put at stack's top)

arguments are transferred through CPU registers
 

Question 2
/ 1 pts
The term "cdecl" refers to a name of:

a contemporary version of the "C" programming language
Correct!
  
a way of passing arguments to function
 

an obsolete version of the "C" programming language
  
an obsolete compilers family
 

Question 3
/ 1 pts
Which of the following function headers is invalid?
  
void f0(char *s, int n, ...)
 
Correct!
  
void f0(int n, ..., char *s)
 
  
void f0(int n, char *s)
 
  
void f0(int n, char *s, ...)
 

Question 4
/ 1 pts
A variadic function is a function which:
  
changes its address during program execution
 
  
changes its name during program execution
 
  
accepts more than one invocation at a time
 
Correct!
  
accepts varying number of arguments
 

Question 5
/ 1 pts
The va_arg, an identifier coming from <stdarg.h>, actually is a:
  
variable
 
  
function
 
  
type
 
Correct!
  
macro
 

Question 6
/ 1 pts
What is the expected output of the following code?
#include <stdarg.h>
#include <stdio.h>
int f(int n, ...) {
va_list list;
va_start(list,n);
n = va_arg(list,int);
va_end(list);
return n;
}

int main(void) {
printf("%d\n", f(1, 2, 3, 0));
return 0;
}
Correct!
  
2
 
  
0
 
  
1
 
  
3
 

Question 7
/ 1 pts
The vsprintf() function has the following prototype:
Correct!
  
int vsprintf(char *str, char *format, va_list ap);
 
  
int vsprintf(char *format, va_list ap);
 
  
int vsprintf(char *str, char *format);
 
  
int vsprintf(char *str, char *format, ...);
 

Question 8
/ 1 pts
A function with following header:
int max(int n, va_list vals)

needs a va_start(n, vals) invocation at the body's beginning
  
doesn't need a va_start() invocation
 

needs a va_start(vals) invocation at the body's beginning
Correct!

needs a va_start(vals, n) invocation at the body's beginning

Question 9
/ 1 pts
Only one of the following macro definitions is valid ‑ which one?
Correct!
  
#define VARMAC(x,...) fprintf(x, __VA_ARGS__)
 
  
#define VARMAC(x) fprintf(x, __VA_ARGS__)
 
  
#define VARMAC(...,x) fprintf(x, __VA_ARGS__)
 
  
#define VARMAC(...) fprintf(x, __VA_ARGS__)
 

Question 10
/ 1 pts
What is the expected output of the following program?
#include <stdio.h>
double x(double x, ...) {
va_list l;
double s = x, v;
va_start(l,x);
do {
v = va_arg(l,double);
s += v;
} while(v != 0.0);
return s;
}
int main(void) {
printf("%f\n",x( -2., -1., 0., 1., 2., 0.));
return 0;
}
  
-2.000000
 
  
2.000000
 
  
3.000000
 
Correct!
  
-3.000000
 

Question 11
/ 1 pts
In the "stdcall" arguments passing convention:
Correct Answer
  
the invoker cleans the stack
 
  
the stack is always clean
 
You Answered
  
the invokee cleans the stack
 
  
the stack is cleaned periodically by OS
 

Question 12
/ 1 pts
The stack (understood as an abstract data type) is often referred to as:
Correct!
  
LIFO
 
  
LILO
 
  
FILO
 
  
FIFO
 

Question 13
/ 1 pts
The following trigraph is named:
...
  
a parabola
 
  
a hyperbole
 
Correct!
  
an ellipsis
 
  
a threedot
 

Question 14
/ 1 pts
A header file, needed for variadic argument list processing, is named:
  
stdvar.h
 
Correct!
  
stdarg.h
 
  
vararg.h
 
  
varstd.h
 

Question 15
/ 1 pts
Copying one instance of va_list to another is done by:
  
memcpy() function
 
Correct!
  
va_copy() function
 
  
memmove() function
 
  
strcpy() function
 

Question 16
/ 1 pts
Which of the presented snippets should be put into the code to make it work properly?
#include <stdarg.h>
#include <stdio.h>
double sum(int n, ...) {
va_list list;
double s = 0;
va_start(list,n);
while(n--) {
s += va_arg(list,double);
}
va_end(list);
return s;
}

int main(void) {
double v;
/* put a line here */
printf("%f\n", v);
return 0;
}
Correct!
  
v = sum(3, 1., 2., 3.);
 
  
v = sum(3, 1L, 2L, 3L);
 
  
v = sum(3, 1.);
 
  
v = sum(3, 1., 2.);
 

Question 17
/ 1 pts
A list of values stored in variable of type va_list may be passed to a function as an argument, but the variable:
  
must not be passed as the last argument
 
Correct!

must be properly instantiated before the invocation by means of va_start() function
  
must not be passed as the first argument
 
  
must not be the only argument
 

Question 18
/ 1 pts
A macro, writing a formatted string to stderr stream, may be implemented as:
Correct!
  
#define PRERR(...) fprintf(stderr, __VA_ARGS__)
 

#define PRERR(...) fprintf(stderr, "__VA_ARGS__")
 

#define PRERR(...) fprintf(stderr, #__VA_ARGS__)
 
  
#define PRERR(...) fprintf(stderr, ...)
 

Question 19
/ 1 pts
What is the expected output of the following code?
#include <stdio.h>
#define VMAC(...) printf("%s\n", #__VA_ARGS__)
int main(void) {
char *s = "macro";
VMAC(s,s,s);
return 0;
}
  
macro,macro,macro
 
Correct!
  
s,s,s
 
  
sss
 
  
macromacromacro
 

Question 20
/ 1 pts
What is the expected output of the following program?
#include <stdio.h>
double x(double x, double y, double z, ...) {
va_list l;
double s = x, v;
va_start(l,z);
do {
v = va_arg(l,double);
s += v;
} while(v != 0.0);
return s;
}
int main(void) {
printf("%f\n",x( -2., -1., 0., 1., 2., 0.));
return 0;
}
  
0.000000
 
  
-2.000000
 
  
3.000000