Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. In the following C program fragment j, k n and Two Log_n are integer variables, and A is an array of integers. The variable n is initialized to an integer ≥ 3, and
    TwoLog_n is initialized to the value of 2 *

    for (k = 3; k < = n; k + +)
        A [k] = 0;
    for (k = 2; k < = TwoLog_n; k + +)
       for (j = k + 1; j < = n; j + +)
       A[j] = A[j] || (j%k);
       for (j = 3; j < = n; j + +)
        if (!A[j]) printf (“%d”, j);
    The set of numbers printed by this program fragment is
    1. {m | m ≤ n (∃i) [m = i!]}
    2. {m | m ≤ n, (∃i) [m = i2]}
    3. {m | m ≤ n, (m is prime)}
    4. {}
Correct Option: B

If (!A[J]) condition was as follows
(!A[J]) = = 0)
Then, it prints a non zero value in the array
{m | m ≤ n, (Ei) [m = i2]}



Your comments will be displayed only after manual approval.