Chuyển đến nội dung chính

Test C/C++


Exam
Chapter 1 Assessment (CPA)
Time left: 17:53
Top of Form
Which of the following strings is a proper integer number (in the "C++" language sense)?
Select correct answer (single choice)
 3E14
 314
 3.14
 3,14 

What is the value of the following literal?
he 8.
    010
   
 
Select correct answer (single choice)
 10
 the literal is invalid
 2
 8 

What is the value of the following literal?

    X10
   
 

Select correct answer (single choice)
 10
 16
 the literal is invalid
 2 

What is the value of the following literal?

    018
   
 

Select correct answer (single choice)
 the literal is invalid
 2
 16
 10 

What is the value of the following literal?

    -1e-1
   
 

Select correct answer (single choice)
 -10.0
 -1.0
 -0.1
 the literal is invalid 

What is the value of the x variable?

    float x = 1. / 2. + 2. / 4.;
   
 

Select correct answer (single choice)
 0.25
 0.75
 1.0
 0.5 

What is the value of the k variable?

    int k = 1 % 2 + 4 % 2;
   
 

Select correct answer (single choice)
 1
 3
 2
 0 

What is the final value of the k variable?

    int i = 3, j, k;
    if(i > 0) j = 2 + i * i;
    if(i <= 0) j = 2 * i - 1;
    if(j >= 0) k = j % i + 2;
    if(j < 0) k = i % j + 2;
    if(k < 0) k = k % i % j;
    if(k >= 0) k = j % i % k;
   
 

Select correct answer (single choice)
 -1
 1
 -2
 2 

What is the final value of the k variable?

    int i = 3, j = 2, k = -1;
    if(i > 0) {
        if(j <= 0) {
            if(k < 0)
                k++;
            if(k <= 0)
                k--;
        }
        if(j > 0)
            i++;
    }
    if(i <= 0)
        j++;
    k = i + j + k;
   
 

Select correct answer (single choice)
 3
 6
 4
 5 

What is the output of the following snippet if a digit 5 followed by Enter is entered through the keyboard?

    int i = 3, j = ++i, k = ++i;
    cin >> i;
    cout << k + i << j - i << i * i;
   
 

Select correct answer (single choice)
 10-545
 10545
 10-125
 10125 
Bottom of Form
          


Exam

Chapter 2 Assessment (CPA)

Time left: 13:00


What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    int main() {
            int i = 5, j = 0;
            while(i > 0) {
                i--;
                j++;
            }
            cout << j;
            return 0;
    }
    
 
Select correct answer (single choice)
 3 
 4 
 2 
 5 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    int main() {
            int i = 3, j = 0;
            do {
                i--;
                j++;
            } while(i >= 0);
            cout << j;
            return 0;
    }
    
 

Select correct answer (single choice)
 5 
 2 
 4 
 3 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    int main() {
            for(float val = -10.0; val < 100.0; val = -val * 2) {
                if(val < 0 && -val >= 40)
                    break;
                cout << "*";
            }
            return 0;
    }
    
 

Select correct answer (single choice)
 ** 
 *** 
 **** 
 ***** 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    int main() {
            int a = 1, b = 2;
            int c = a | b;
            int d = c & a;
            int e = d ^ 0;
            cout << e << d << c;
            return 0;
    }
    
 

Select correct answer (single choice)
 131 
 113 
 031 
 100 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    int main() {
            int a = 1, b = 2;
            int c = a << b;
            int d = 1 << c;
            int e = d >> d;
            cout << e;
            return 0;
    }
    
 

Select correct answer (single choice)
 2 
 4 
 1 
 0 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    int main() {
            int a = 2;
            switch(a << a) {
            case 8 : a++;
            case 4 : a++;
            case 2 : break;
            case 1 : a--;
            }
            cout << a;
            return 0;
    }
    
 

Select correct answer (single choice)
 5 
 2 
 4 
 3 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    int main() {
            int t[] = { 5, 4, 3, 2, 1 }, i;
            for(i = t[4]; i < t[0]; i++)
                t[i - 1] = -t[3];
            cout << i;
            return 0;
    }
    
 

Select correct answer (single choice)
 2 
 4 
 5 
 3 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    
    struct str {
        int t[3];
        char s[3];
    };
    
    int main() {
            str z[3];
            for(int i = 0; i < 3; i++) 
                for(int j = 0; j < 3; j++) {
                    z[i].s[j] = '0' + i + j;
                    z[j].t[i] = i + j;
                }
            cout << z[0].s[1] << z[1].t[2] << z[2].s[0];
            return 0;
    }
    
 

Select correct answer (single choice)
 312 
 132 
 123 
 032 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    
    struct sct {
        int t[2];
    };
    
    struct str {
        sct t[2];
    };
    
    int main() {
            str t[2] = { {0, 2, 4, 6}, {1, 3, 5, 7} };
            cout << t[1].t[0].t[1] << t[0].t[1].t[0];
            return 0;
    }
    
 

Select correct answer (single choice)
 43 
 34 
 52 
 25 

What is the output of the following snippet?

    #include <iostream>
    using namespace std;
    
    int main() {
            char arr[5] = { 'a', 'b', 'c', 'd', 'e' };
            for(int i = 1; i < 5; i++) {
                cout << "*";
                if((arr[i] - arr[i - 1]) % 2)
                    continue;
                cout << "*";
            }
            return 0;
    }
    
 

Select correct answer (single choice)
 ******* 
 ******** 
 **** 
 ***** 
          


Exam

Chapter 1 Assessment (CLA)

Time left: 25:52

The English language is an example of: 
Select correct answer (single choice)
 a natural language 
 a machine language 
 a programming language 

A high-level language is:
Select correct answer (single choice)
 a language spoken by mountain tribes 
 a type of a programming language 
 a language spoken in the high society 

A compiler is:
Select correct answer (single choice)
 a computer program designed to translate programs from a machine language into a high-level language 
 a computer program designed to translate programs from a high-level language into a machine language 
 an alternative name for a processor 

Data of type int is:
Select correct answers (multiple choice)
 an internal number 
 a fractional number 
 an integral number 
 an integer number 

The following string:

    ThisIsTheNameOfTheVariable
 
Select correct answer (single choice)
 may be used as a variable name 
 must not be used as a variable name 

The following string:
    101Dalmatians

Select correct answer (single choice)
 may be used as a variable name 
 must not be used as a variable name 

What is the value of the var variable after the execution of the following snippet of code:
    int var;
    var = 100;
    var = var + 100;
    var = var + var;

Select correct answer (single choice)
 100 
 400 
 300 
 200 

A keyword is a word which:
Select correct answer (single choice)
 is the most important word in a program 
 functions as a password needed to launch a program 
 must not be used in the meaning other than defined in the language standard 

A comment placed anywhere inside the code is a syntactical equivalent of:
Select correct answer (single choice)
 a keyword 
 a space 
 a number 

Every variable has the following attributes:
Select correct answer (single choice)
 header, footer, setter 
 type, name, value 
 variability, stability, readability 
          


Exam

Chapter 2 Assessment (CLA)

Time left: 39:33

Which of the following strings is a proper integer number (in the “C” language sense)?
Select correct answer (single choice)
 123_456 
 123,456 
 123.456 
 123456 

What is the value of the following integer literal?

    08
 
Select correct answer (single choice)
 10 
 the literal is invalid 
 1000 
 8 

What is the value of the following integer literal?

    0x8
 

Select correct answer (single choice)
 8 
 10 
 1000 
 the literal is invalid 

Which of the following strings is a valid variable name?
Select correct answer (single choice)
 Monte Carlo 
 Monte_Carlo 
 Monte@Carlo 
 Monte-Carlo 

Which of the following strings is an invalid variable name?
Select correct answer (single choice)
 _0_ 
 ___ 
 0_ 
 _0 

Is the following declaration valid?
    int var, var;

Select correct answer (single choice)
 No 
 Yes 

What is the value of the var variable at the end of the following snippet?
    int var;
    var = 2;
    var = var * var;
    var = var + var;
    var = var / var;
    var = var – var;

Select correct answer (single choice)
 0 
 1 
 16 
 8 

What is the value of the var variable at the end of the following snippet?
    int var;
    var = 2;
    var = var * var;
    var = var + var;
     /*
    var = var / var;
    var = var – var;
      */

Select correct answer (single choice)
 16 
 1 
 0 
 8 

Which of the following strings is a proper floating-point number (in the “C” language sense)?
Select correct answer (single choice)
 123456 
 123,456 
 123.456 
 123_456 

What is the value of the following floating-point literal?
    8765E-2

Select correct answer (single choice)
 87.65 
 876.5 
 8.765 
 0.8765 

What is the value of the x variable at the end of the following snippet?
    int x;
    
    x = 1 / 2;

Select correct answer (single choice)
 0 
 1 
 2 
 0.5 

What is the value of the x variable at the end of the following snippet?
int x;
x = 1 / 2 * 3;
/***
Select correct answer (single choice)
 2 
 0 
 1.5 
 1 

What is the value of the x variable at the end of the following snippet?
float x;
x = 1. / 2 * 3;
/***
Select correct answer (single choice)
 2 
 1.5 
 0 
 1 

What is the value of the k variable at the end of the following snippet?
    int i,j,k; 
    
    i = 4; 
    j = 5; 
    k = --i * j++;

Select correct answer (single choice)
 12 
 18 
 16 
 15 

What is the value of the k variable at the end of the following snippet?
    int i,j,k; 
    
    i = 4; 
    j = 5; 
    k = i-- * ++j;

Select correct answer (single choice)
 21 
 28 
 18 
 24 

What is the value of the k variable at the end of the following snippet?
    int i,j,k; 
    
    i = 3; 
    j = -3; 
    k = i * j; 
    k += j; 
    k /= i;

Select correct answer (single choice)
 -4 
 4 
 8 
 -8 

What is the value of the c variable at the end of the following snippet?
    char c;
    
    c = '\';

Select correct answer (single choice)
 \ 
 ' 
 the assignment is invalid and causes a compilation error 
 \0 

What is the value of the c variable at the end of the following snippet?
    char c;
    
    c = 'a';
    c -= ' ';

Select correct answer (single choice)
 the assignment is invalid and causes a compilation error 
 a 
 A 
 \0 

What is the value of the k variable at the end of the following snippet?
    int i,j,k; 
    
    i = 3; 
    j = -3; 
    k = (i >= i) + (j <= j) + (i == j) + (i > j);

Select correct answer (single choice)
 2 
 1 
 3 
 0 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i,j,k; 
        i = 2; 
        j = -2; 
        if(i) 
                i--; 
        if(j) 
                j++; 
        k = i * j; 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 2 
 the program outputs -1 
 the program outputs -2 
 the program outputs 1 
          


Exam

Chapter 3 Assessment (CPA)

Time left: 25:43

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int main() {
        int t[3] = { 3, 2, 1 }, *ptr = t + 1;
        (*(ptr + 1))++;
        *ptr++;
        cout << t[1] << t[2];
        return 0;
    }
    
 
Select correct answer (single choice)
 23 
 22 
 32 
 33 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int main() {
        float x = 3.14, *p = &x;
        p[0] = ++x;
        cout << x;
        return 0;
    }
    
 

Select correct answer (single choice)
 0.0 
 4.14 
 3.14 
 6.28 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int main() {
        int tab[5] = { 1, 2, 4, 8, 16 };
        int *p1 = tab, *p2 = tab + 4;
        for(int *p = p1 + 1; p < p2; p++)
            *p = p[-1] * 2;
        cout << tab[1] << tab[2];
        return 0;
    }
    
 

Select correct answer (single choice)
 24 
 12 
 48 
 01 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    float fun(float arg) {
        return arg * arg + arg + 1;
    }
    
    int main() {
        cout << fun(fun(1.0));
        return 0;
    }
    
 

Select correct answer (single choice)
 13 
 10 
 7 
 16 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int fun(float a, float b) {
        return a / b;
    }
    
    int main() {
        cout << fun(fun(1.0,2.0),fun(2.0,1.0));
        return 0;
    }
    
 

Select correct answer (single choice)
 1 
 -1 
 2 
 0 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int f1(int *a) {
        return *a + 1;
    }
    
    int *f2(int *a) {
        return a + 1;
    }
    
    int *f3(int &a) {
        return &a + 1;
    }
    
    int main() {
        int t[] = {0, 1, 2, 3};
        cout << f1(f3(*f2(t)));
        return 0;
    }
    
 

Select correct answer (single choice)
 2 
 3 
 1 
 0 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int fun(int a, int b) {
        return a + b;
    }
    
    int fun(int a, char b) {
        return b - a;
    }
    
    int fun(float a, float b) {
        return a * b;
    }
    
    int main() {
        cout << fun(1,0) << fun('a','c') << fun(2.f,2.f);
        return 0;
    }
    
 

Select correct answer (single choice)
 481 
 248 
 012 
 124 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int fun(long a, long b = 1) {
        return a << b;
    }
    
    int fun(int a, char b = 'z') {
        return b - a;
    }
    
    int fun(float a, float b = 0) {
        return a * b;
    }
    
    int main() {
        cout << fun(1L) << fun('x') << fun(2e0f);
        return 0;
    }
    
 

Select correct answer (single choice)
 234 
 220 
 121 
 112 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    int *make(int v) {
        int *p = new int;
        *p = v + 1;
        return p;
    }
    int *play(int &v) {
        cout << ++v;
        return &v;
    }
    
    void remove(int *v) {
        delete v;
    }
    
    int main() {
        remove(play(*make(3)));
        return 0;
    }
    
 

Select correct answer (single choice)
 2 
 3 
 4 
 5 

What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    struct s {
        float *f;
    };
    
    void make(s *p, float x = 10) {
        float *f = new float; 
        *f = sizeof(*f) / sizeof(float) * 10;
        p->f = f;
    }
    
    int main() {
        s *ss = new s;
        make(ss);
        cout << *(*ss).f;
        delete ss->f;
        delete ss;
        return 0;
    }
    
 

Select correct answer (single choice)
 20 
 40 
 10 
 80 
          


Exam

Chapter 4 Assessment (CPA)

Time left: 19:26


What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    
    int main() {
        float *ft[3] = { new float[3], new float[3], new float[3] }, *p;
        
        for(int i = 0; i < 3; i++) {
            p = ft[i];
            *p = p[1] = *(p + 2) = 10 * i;
        }
        cout << ft[1][1];
        delete [] ft[0];
        delete [] ft[1];
        delete [] ft[2];
        return 0;
    }
    
 
Select correct answer (single choice)
 It prints 30 
 It prints 10 
 It prints 20 
 Compilation fails 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    
    int main() {
        short s = 1;
        int i = 2;
        long l = 3;
        float f = 4.4;
        double d = 6.6;
        
        cout << s/float(i) + int(f)/i + long(d)/s;
        return 0;
    }
    
 

Select correct answer (single choice)
 It prints 8.5 
 It prints 8.8 
 Compilation fails 
 It prints 8.0 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    
    int main() {
        int i = 2;
        float f = 5.8;
        
        f = (int)f;
        i = (float) i;
        cout << f/i;
        return 0;
    }
    
 

Select correct answer (single choice)
 Compilation fails 
 It prints 3 
 It prints 2 
 It prints 2.5 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
        int i = 2;
        string s = "2";
        
        cout << s + i;
        return 0;
    }
    
 

Select correct answer (single choice)
 It prints 4 
 Compilation fails 
 It prints 22 
 It prints 2 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    
    int main() {
        string s1 = "Ab";
        string s2 = "Abc";
        
        cout << s1.compare(s1);
        return 0;
    }
    
 

Select correct answer (single choice)
 It prints 1 
 It prints -1 
 Compilation fails 
 It prints 0 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    
    int main() {
        string s1 = "1";
        string s2 = "12";
        
        cout << s1.compare(s2);
        return 0;
    }
    
 

Select correct answer (single choice)
 It prints -1 
 It prints 0 
 Compilation fails 
 It prints 1 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
        string s = "ABCDEF";
        for(int i = 1; i < s.length(); i += 2)
            s[i - 1] = s[i] + 'a' - 'A';
        cout << s;
        return 0;
    }
    
 

Select correct answer (single choice)
 Compilation fails 
 It prints BBDDFF 
 It prints bBdDfF 
 It prints aAcCeE 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
        string s = "AB";
        s.append(s).push_back(s[s.length() - 1]);
        cout << s;
        return 0;
    }
    
 

Select correct answer (single choice)
 It prints ABABB 
 Compilation fails 
 It prints ABAB 
 It prints ABABA 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
        string s1 = "aleph";
        string s2 = "alpha";
        string s;
        s1.swap(s2);
        s2.swap(s);
        s.swap(s2);
        cout << s2;
        return 0;
    }
    
 

Select correct answer (single choice)
 It prints an empty string 
 Compilation fails 
 It prints aleph 
 It prints alpha 

What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    
    namespace S {
    int A = 1;
    }
    
    namespace S {
    int B = A + 2 ;
    }
    
    int main(void) {
        S::A = S::A + 1;
        { using namespace S;
           ++B;
        }
        cout << S::B << S::A;
        return 0;
    }
 

Select correct answer (single choice)
 Compilation fails 
 It prints 42 
 It prints 32 
 It prints 22 

       
Exam

Chapter 3 Assessment (CLA)

Time left: 17:19

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i, j, k; 
        i = -1; 
        j = 1; 
        if(i) 
                j--; 
        if(j) 
                i++; 
        k = i * j; 
        printf("%d",k); 
        return 0; 
    }
Select correct answer (single choice)
 the program outputs 2 
 the program outputs -1 
 the program outputs 0 
 the program outputs 1 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i, j, k; 
        i = 0; 
        j = 0; 
        if(j) 
                j--; 
        else 
                i++; 
        if(i) 
                i--; 
        else 
                j++; 
    
        k = i + j; 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 2 
 the program outputs 0 
 the program outputs -1 
 the program outputs 1 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i, j, k; 
        i = 2; 
        j = 3; 
        if(j) 
                j--; 
        else if(i) 
                i++; 
        else 
                j++; 
        if(j) 
                i--; 
        else if(j) 
                j++; 
        else 
                j = 0; 
        k = i + j; 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 2 
 the program outputs 1 
 the program outputs 3 
 the program outputs 0 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        double x = -.1; 
        int i = x; 
        printf("%d",i); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 0.100000 
 the program outputs -0.100000 
 the program outputs 0 
 the program outputs -1 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        float x,y; 
        int i,j; 
        x = 1.5; y = 2.0; 
        i = 2; j = 3; 
        x = x * y + i / j; 
        printf("%f",x); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 2.000000 
 the program outputs 3.000000 
 the program outputs 1.000000 
 the program outputs 0.000000 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        float x,y; 
        int i,j; 
        x = 1.5; y = 2.0; 
        i = 2; j = 4; 
        x = x * y + (float)i / j; 
        printf("%f",x); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 4.000000 
 the program outputs 3.000000 
 the program outputs 3.500000 
 the program outputs 2.000000 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i; 
        i = 1; 
        while(i < 16) 
                i *= 2; 
        printf("%d",i); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 8 
 the program outputs 4 
 the program outputs 16 
 the program outputs 32 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i, j; 
        i = 1; j = 1; 
        while(i < 16) { 
                i += 4; 
                j++; 
        } 
        printf("%d",j); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 7 
 the program outputs 4 
 the program outputs 5 
 the program outputs 6 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 7, j = i - i; 
        while(i) { 
                i /= 2; 
                j++; 
        } 
        printf("%d",j); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 3 
 the program outputs 1 
 the program outputs 2 
 the program outputs 0 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 7, j = i - i; 
        while(!i) { 
                i /= 2; 
                j++; 
        } 
        printf("%d",j); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 3 
 the program outputs 2 
 the program outputs 0 
 the program outputs 1 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i, j = 1; 
        for(i = 11; i > 0; i /= 3) 
                j++; 
        printf("%d",j); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 4 
 the program outputs 3 
 the program outputs 2 
 the program outputs 5 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i, j = 0; 
        for(i = 0; !i ; i++) 
                j++; 
        printf("%d",j); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 3 
 the program outputs 0 
 the program outputs 2 
 the program outputs 1 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 1, j = -2; 
        for(;;) { 
                i *= 3; 
                j++; 
                if(i > 30) 
                        break; 
        } 
        printf("%d",j); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 3 
 the program outputs 1 
 the program outputs 0 
 the program outputs 2 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 1, j = -2, k; 
        k = (i >= 0) && (j >= 00) || (i <= 0) && (j <= 0); 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 1 
 the program outputs 3 
 the program outputs 2 
 the program outputs 0 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 1, j = -2, k; 
        k = (i >= 0) || (j >= 00) && (i <= 0) || (j <= 0); 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 1 
 the program outputs 0 
 the program outputs 2 
 the program outputs 3 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 1, j = -2, k; 
        k = !(i >= 0) || !(j >= 00) && !(i <= 0) || !(j <= 0); 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 0 
 the program outputs 3 
 the program outputs 2 
 the program outputs 1 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 1, j = 0, k; 
        k = i & j; 
        k |= !!k; 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 3 
 the program outputs 1 
 the program outputs 0 
 the program outputs 2 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 1, j = 0, k; 
        k = !i | j; 
        k = !k; 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 2 
 the program outputs 1 
 the program outputs 3 
 the program outputs 0 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 1, j = 0, k; 
        k = (i ^ j) + (!i ^ j) + (i ^ !j) + (!i ^ !j); 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 2 
 the program outputs 1 
 the program outputs 0 
 the program outputs 3 

What happens if you try to compile and run this program?
    #include <stdio.h> 
    int main(void) { 
        int i = 0, j = 1, k; 
        k = i << j + j << i; 
        printf("%d",k); 
        return 0; 
    }

Select correct answer (single choice)
 the program outputs 3 
 the program outputs 1 
 the program outputs 2 
 the program outputs 0 
          
   


Nhận xét

Đăng nhận xét

Bài đăng phổ biến từ blog này

Entry Test của FPT

IQ - Kiểm tra tư duy logic (8/20) - GMAT- Kiểm tra khả năng tính toán trong thời gian ngắn (8/20) - Tiếng Anh (18-> 25/50) - Các bài thi chuyên môn - FE (8/20) IQ: lên mạng tìm "IQ test" là ra đầy. + GMAT: Những câu trắc nghiệm tính toán đơn giản kiểu như sau:  1 . Một shop thời trang sale off quần jeans 15 %, quần jeans giá 450 $, người mua đưa 500 $, hỏi cashier trả lại bao nhiêu $ tiền thừa.? 2 . 100 % là 180 , vậy 150 là bao nhiêu %? Tiếng anh: Cỡ như thi TOEIC thôi. Chuyên môn: Mobile thì trắc nghiệm Java. Qúa trình tuyển như sau :v Lần 1: Test IQ, Tiếng Anh( mình làm í ẹ khoảng 50% mà vẫn được) , Java Lân 2: được gọi điện lên :)) + Gioi thiệu bản thân + Họ chỉ hỏi các câu căn bản như: -. OOP: là gì, 4 tính chất, ví dụ, khác nhau giữa interface và abstract - CODE: hầu toàn các bài toán vòng for :)) , cẩn thận mấy câu kế thừa. SQL (distinct, view, function, cursor, store procedure, ...v.v.), nhớ có câu cộng 2 số int không dùng biến đệm hơi khoai haha + Nói ch...

Java: Java Package-Thư viện trong Java

Giới thiệu về Package Các bạn mới học lập trình Java thường không dể ý tới package vì các bạn toàn tạo file .java vào cùng 1 chỗ, không cần sắp xếp, không cần quản lý truy nhập. Nhưng để tăng kỹ năng lập trình với Java, các bạn cần phải tìm hiểu về package trong Java. Các bạn có thể tham khảo định nghĩa sau: Package được dùng để đóng gói các lớp trong chương trình lại với nhau thành một khối. Đây là cách tốt nhất để lưu trữ các lớp gần giống nhau hoặc có cùng một module thành một khối thống nhất – để đáp ứng 1 khối chức năng. Từ đây mình sẽ giới thiệu thêm với các bạn các câu lệnh nhâp khẩu,nó có định dạng như sau : Định dạng :  import javaPackageNameImport;    Nó giống như khai báo thư viện ở các ngôn ngữ lập trình khác.Như vậy,chỉ khi các bạn nhập khẩu chúng,các bạn mới có thể sử dụng thư viện mà chúng cung cấp cho ta. VD :    import java.util.Date;   import java.text.SimpleDateFormat; Lưu ý : -Các câu lệnh nhập khẩu rất nhiều và...

Khác nhau giữa Array và ArrayList và HashMap

Collection bản chất là tập các lớp dùng để lưu trữ danh sách và có khả năng tự co giãn khi danh sách thay đổi : Thêm , sửa , xóa , chèn … Hai lớp Collection thường được sử dụng nhiều nhất là ArrayList và Hashmap Giới thiệu về ArrayList ArrayList sử dụng cấu trúc mảng để lưu trữ phần tử , tuy nhiên có hai đặc điểm khác mảng : Không cần khai báo trước kiểu phần tử . Không cần xác định trước số lượng phần tử ( kích thước mảng ). N ó có kh ả năng truy c ậ p ph ầ n t ử ng ẫ u nhiên (Do th ừ a k ế t ừ interface RandomAccess ). P hương thức khởi tạo ● ArrayList () ● ArrayList (Collection c) ● ArrayList ( int initialCapactity ) Các phương thức chính ● add(Object o) ● remove(Object o) ● get( int index) ● size() ● isEmpty () ● contains(Object o) ● clear() Giới thiệu về HashMap ● Là ki ể u t ậ p h ợ p t ừ đ i ể n, HashMap cho phép truy xu ấ t tr ự c ti ế p t ớ i m ộ ...