CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

In the following C program fragment j, k, n and TwoLong_n are integer variables, and A is an array of integers. The variable n is initialized to an integer 3, and TwoLong_n is initialized to the value of
2log2(n)

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

A
{m m n, (i) [m = i2!]}
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
{m m n, (i) [m = i!]}
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
{ }
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
{m m n, m is prime}
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is C { }
1. First for loop fill array with '0' from index 3 to n.

2. Second for loop location where index j is not multiple of k i.e. non multiple index of k and update index of non multiple index of 4 as 1.

Since we are updating one array A as 1 because of we are doing step 2 for every value of 2 to 2×log2n.

So if (!A[j]) will return false for each index of array 4 because we set each index in step 2. So it will print nothing

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Functions
QUANTITATIVE APTITUDE
Watch in App
Join BYJU'S Learning Program
CrossIcon