Advanced C | Final Test

  1. The following symbol may be(in certain circumstances) taken as an equivalent of:

    :>
    • a tilde
    • a parenthesis
    • a bracket
    • a hash
  2. The regular IP address consists of:

    • 4 octets 
    • 2 octets 
    • 1 octets 
    • 8 octets 
  3. Resolving a host’s name based on given IP address can be done by invoking:

    • get IP()
    • getservbyname()
    • gethostbyname()
    • getIPaddr()
  4. Select the true statement:

    • a variable may be const and volatile at the same time
    • const – volatile variable may be explicitly modified in the code containing its declaration
    • const – volatile variable must not be implicitly modified by the background process
    • a compiler will try to store the const – volatile variable in CPU registers
  5. The string literal passed to _Pragma keyword is the subject of:

    • deliteration
    • dereferencing
    • defragmentation
    • destringization
  6. The following snippet:

    int f(int i){
         i++;
         if( i == 0) goto go_to;
         retrun i;
    }
    
    int main(void) {
        f(0);
    go_to:
        return 0;
    }
    • is fully correct 
    • will cause compilation error
    • will cause infinite loop
    • will cause runtime error
  7. The “endline translation” occurs when the fine is opened with o_TEXT flag and takes place during:

    • lseek() function invocation
    • reads only
    • writes only
    • reads and writes
  8. The _Bool keyword, introduced by C11, denotes a type being an equivalent of:

    • unsigned char
    • boolean
    • void
    • unsigned int
  9. A variable function is a function which:

    • changes its name during program execution 
    • accepts more than one invocation at a time 
    • changes its address during program execution 
    • accepts varying number of arguments
  10. A working process if identified by:

    • name of program used to start the process
    • user’s name 
    • source device
    • its unique PID
  11. The exec() family functions:

    • return to invoker in case of success
    • never return to invoker
    • return to invoker in case of error 
    • always return to invoker
  12. The spawn() family functions:

    • never return to invoker
    • return to invoker in case of error 
    • return to invoker in case of success
    • always return to invoker
  13. 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);
        char c;
        while(va_arg(list,int)!=0)
             c = va_arg(list, int);
        va_end(list);
        return c;
    }
    
    int main(void){
        printf("[%c]\n", f('a','b','c','\0'));
        return 0;
    }
    • c
    • b
    • a
    • an empty line
  14. The following symbol may be (in certain circumstances) taken as an equivalent of:
    ??'

    • a hash 
    • a tilde
    • a caret
    • a parenthesis
  15. Assuming that the code was compiled and ran in Unix/Linux environment what is its expected output?

    #include <sys/types.h>
    #include <sys/wait.h>
    #include <stdio.h>
    #include <unistd.h>
    int x = 0;
    int main(void){
        if(fork()){
                wait(NULL);
                    printf("%d", x);
                return 0;
        }eles {
                   x++;
                return 0;
        }
    }
    • 0
    • 2
    • an empty line
    • 1
  16. Which of the expressions can be used to discover that read() invocation reached end of file?

    • read(fd, t, sizeof(t)) > 0
    • read(fd, t, sizeof(t)) == 0
    • read(fd, t, sizeof(t)) < 0
    • read(fd, t, sizeof(t)) == sizeof(t)
  17. What is possible output of the following program?

    #include <stdio.h>
    int main(int argc, char * argv[]) {
        puts(*argv);
        return 0;
    }
    • an empty 
    • zero
    • a line containing program name
    • a random string 
  18. The volatile specifier:

    • is obsolete
    • forces the compiler to fetch the variable from memory each time it is read
    • tells the compiler to not use the variable 
    • suggest the compiler to store the variable in one of CPU registers
  19. The file descriptor of value equal to 1 :

    • is connected to stdout
    • is connected to stderr
    • is not connected and may be freely used
    • is connected to stdin
  20. What is the expected output of the following code?

    #include <string.h>
    #include <stdio.h>
    int main(void) {
        char p[] = "10101", *q;
        int i = 0;
        q = strtok(p, "0");
        while(q) {
               i++;
               q = strtok(NULL, "0");
        }
        printf("%d\n", i);  
        return 0;
    }
    • 3
    • 2
    • the code fails in an infinitive loop
    • 1
  21. What should be placed instead of <?> to make the following snippet work properly?

    if(<?> access("input", W_OK)) {
        puts("File could not be written");
        exit(1);
    }
    • 0 >
    • 0 <
    • 0 ==
    • NULL ==
  22. The memory block allocated by malloc() function:

    •  is filled with zeros
    • is filled with 0xFF
    • is filled with 0xdeadbeef
    • is filled with random values
  23. The ellipsis (...) used in a function header, may be:

    • the first element on parameters list
    • the only element on parameters list
    • surrounded by brackets
    • preceded by parameter of pointer type
  24. The UDP protocol:

    • provides reliable communication channel 
    • does not provide any communication channel 
    • is only able to transmit datagrams 
    • provides unreliable communication channel
  25. The shortest part of a double value is:

    • exponent
    • significand
    • sign
    • all parts have equal sizes
  26. Removing the letter ‘f‘ from both literals used in the following expression:

    • will change the value printed to stdout
    • won’t change the value printed to stdout
    • will cause runtime error 
    • will make the expression syntactically incorrect
  27. The GMP library uses the mpf_t type to represent:

    • multiprecision float 
    • mulitprecision double vales 
    • mulitprecision rational values
    • mulitprecision integer values
  28. The wcscpy() function is

    • not a member of any standard library 
    • a “wide” version of strcpy()
    • used to invoke C# programs
    • used to invoke Python programs
  29. The result of the following expression:

    int n = '9' - '1';
    • is always 8
    • depends on encoding system used by specific hardware platform
    • is always 6
    • is always 7
  30. The setjmp() function performs its return sequence:

    • usually twice
    • not more than once 
    • always once
    • more than twice
  31. The following snippet:

    int const v  1;
    int const * const p = &v;
    • is fully correct 
    • may cause runtime error 
    • will cause compiler error
    • may cause compiler warning 
  32. The FP_SUBNORMAL flag marks a float value that:

    • has been successfully normalized
    • cannot be normalized 
    • exceeds any of IEEE defines limits
    • has to be normalized
  33. The so-called “network order” is identical to:

    • little-endian order
    • big-endian order
    • target hardware platform order
    • native hardware platform order
  34. To store UNICODE code points the UTF-8 uses:

    • 32 bits
    • 16 bits
    • 8 bits
    • varying number of bits
  35. The “st_dev” filed of “struct stat” in MS Windows environment reflects:

    • 32 bit long device identifier
    • the drive number
    • device location
    • device vendor’s name
  36. The normalized float value:

    • has the highest exponent’s bit set to 0
    • has the highest significand’s bit set to 1
    • has the highest significand’s bit set to 0
    • has the highest exponent’s bit set to 0
  37. The following declarator declarations the fun symbol as:

    void (*fun) (int *, int*);
    • a void pointer
    • a pointer to function returning void
    • a pointer to vid 
    • a pointer to function return pointer to void
  38. According to C11 standard, the __func__ symbol is a:

    • parameterless function 
    • parameterless macro
    • global variable 
    • parameterized macro
  39. Which of the following statements is true?

    • both trigraphs and digraphs are recognized inside string literals
    • trigraphs are recognized inside string literals, digraphs aren’t 
    • trigraphs are not recognized inside string literals, digraphs are  
    • both trigraphs and digraphs are not recognized inside string literals
  40. Which of the following main() function’s header is not valid?

    • int main(int argc, char *argv[], char ***env[])
    • int main(inti argc, char *argv[], char **env)
    • int main(int argc, char * argv[])
    • int main(int argc, char * argv[], char * env[])
  41. The MSG_PEEK flag is used in connection with:

    • bind()
    • recvfrom()
    • socket()
    • accept()
  42. Which of the following is a proper bind()​function header?

    • int bind(int sockfd, struct sockaddr * addr, socklen_t  * addrlen);
    • int bind(int sockfd, struct sockaddr  addr, socklen_t  * addrlen);
    • int bind(int sockfd, struct sockaddr  addr, socklen_t  addrlen);
    • int bind(int sockfd, struct sockaddr * addr, socklen_t addrlen);
  43. What is the expected output of the following code ?

    #include <string.h>
    #include <stdio.h>
    int main(void) {
           int i, *p = &i;
           printf("%d\n", memcmp(&i, &p, 4));
           return 0;
    }
    • a number most probably different from zero
    • a number always greater than zero
    • the output is unpredictable 
    • a number always less than zero
  44. Which of the given example is contemporary equivalent of the obsolete function declaration?

    void f(x) float x; {return x * x;}
    • void f() float x; {return  x * x;}
    • float f(float x) {return x * x;}
    • void f(x) float; {return x * x;}
    • void f(float) x; { return x * x;}
  45. Using Winsock, comparing to the BSD sockets:

    • requires some addition initializations
    • requires some additional initializations and terminations
    • is exactly the same 
    • requires some addition terminations
  46. The length of a double typed variable:

    • is define by the “C” language standards
    • is hardware dependent 
    • is user defined
    • is defined by IEEE754 standard
  47. Each invocation of va_start() must be matched by:

    • exactly one matching va_end() invocation
    • at least one matching va_end() invocation
    • not more than one matching va_end() invocation
    • not more than two matching va_end() invocation
  48. The value of the following expression:

    sizeof(wint_t) < sizeof(wchar_t)
    • is always 1
    • is always 0
    • depends on target platform 
    • cannot be determined
  49. In the argument passing convention named “stdcall”

    • the invoker cleans the stack after return 
    • the invoker cleans the stack before return 
    • the stack cleans its state itself
    • the stack is cleaned periodically by OS
  50. A macro named va_arg, comes from:

    • <vargs.h>
    • <stdarg.h>
    • <varg.h>
    • <args.h>
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments