Advanced Input and Output Operations M8 Test

  1. Complete the sentence to make it true: When a function is declared in the following way:

    int fun(int restrict *v1, int *v2) {....}
    • the compiler will check that v1 and v2 don’t cover the same memory are
    • the executable code is expected to be longer 
    • the execution time will be longer
    • the programmer is obliged to ensure that v1 and v2 don’t cover the same memory area
  2. The place where previous side effects have already occurred and none of next side effects have yet occurred is called the:

    • sequence point
    • local point
    • compound point 
    • characteristic point
  3. Choose the right phrase to make the statement true:

    When a variable declaration starts with…

    const int c...
    • …a complier protects it from all indirect modifications
    • …a pointer to such a variable cannot be taken in anyway
    • …the only way of setting its value is to set though its initializer
    • …it cannot be passed as an argument to any function
  4. The two commonly used assembly language syntax conversions are named:

    • Motorola and Intel
    • AT&T and Bell
    • AT&T and Intel
    • Bell and Motorola
  5. The following function:

    int f(int i) {
        if(i == 0) goto 123;
        i++;
    123:
        return i;
    }
    • may cause a runtime error
    • may cause a complier warning 
    • will cause a complier error
    • is fully correct
  6. Which of the following headers is valid?

    • int f(int T[2][2][static 2])
    • int f(int T[2][static 2][2])
    • int f(int T[static 2][2][2])
    • int f(int T[static 2][2][static 2])
  7. The following function prototype:

    int doit(const int * );
    • is a promise that the argument won’t be modified during invocation
    • requires the argument to be a const -qualified pointer
    • requires the argument to be a pointer to a const -qualified value
    • requires the argument to be a literal
  8. One of the following statements is the false-which one?

    • the goto jump may not lead to the inside of  function
    • the goto jump may lead to the outside of a function
    • the goto jump may not lead to the outside of a compound statement 
    • the goto jump may not lead to the inside of a compound statement 
  9. The following snippet:

    int v = 1;
    const int *p = &v;
    • may cause a compiler warning 
    • will cause a compiler error
    • may cause a runtime error
    • is fully correct
  10. The following snippet:

    int const v = 1;
    int const * const p = &v;
    • may cause a runtime error
    • may cause a compiler warning 
    • is fully correct
    • will cause a compiler error
  11. The syntax used in the following snippet is called:

    char​ s[2] ={[1] = 'a', [0] = 'b' };
    • an enumerated initializer
    • a designated initializer
    • an indexed initializer
    • a free initializer
  12. The following snippet:

    printf("%d\n", a * ++a);
    • always outputs 9
    • always outputs 3
    • always outputs 6
    • contains unsequenced side effects and consequently its output is implementation-dependent
  13. To be successfully compiled, the following snippet must be processed by:

    int f(int n, int *v){
        int t[n\];
        while(n){
            t[n\] = v[n\];
            n--;
        }
        return n;
    }
    • a C89 compliant compiler
    • a C99 compliant compiler
    • an ANSI C compliant compiler
    • a C90 compliant compiler
  14. The pointer named p , declared in the following way, is:

    char * const p = "";
    • an invalid declaration
    • a pointer to a const -qualified char
    • const -qualified pointer to a const -qualified char
    • a const -qualified pointer to a char
  15. What should be placed instead of question marks to make the code work properly?

    int main(void) {
        if(setjmp(buf) ?? 0)
           f();
        else
           puts("returned from long jump");
        return 0;
    }
    • >
    • <
    • ==
    • !=
  16. Assuming the following f() function’s declaration, identify the correct example of its invocation:

    void f(char s[1]);
    • f("abc")
    • f("ab")
    • f("a")
    • f("")
  17. The setjmp() function behaves as if it has:

    • on entry and one exit
    • more than one entry and one exit
    • one entry and more than one exit
    • more than one entry and more than one exit
  18. Select the false stetement:

    • const-volatile variable must not be explicitly modified in the code containing its declaretion
    • const-volatile variable must be explicitly modified by the background process
    • a variable must not be const and volatile  at the same time
    • a compiler will avoid storing a const-volatile variable in the CPU registers
  19. The following function:

    int f(int i){
        int n = i;
        if(n < 10) {
    here:
           i++;
           goto here;
        }
    }
    • incorrectly uses the goto statement and will cause a compilation error
    • will cause a runtime error
    • will cause an infinite loop
    • is fully correct
  20. Assuming the following f() function’s declaration, identify the correct example of its invocation containing the shortest argument

    void f(char s[static 3]);
    • f("abc")
    • f("ab")
    • f("")
    • f("a")
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments