...
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023

Programming-for-Output-Problems

Question 27
The output of the following program is
main()
{
static int x[] = {1,2,3,4,5,6,7,8}
int i;
for (i=2; i<6; ++i)
x[x[i]]=x[i];
for (i=0; i<8; ++i)
printf(“%d”, x[i]);
}
A
1 2 3 3 5 5 7 8
B
1 2 3 4 5 6 7 8
C
8 7 6 5 4 3 2 1
D
1 2 3 5 4 6 7 8
Question 27 Explanation: 

For loop will execute for the i value 2,3,4,5
For i = 2, x[x[2]] = x[2]
= x[3] = 3 // since x[2] = 3
The array elements representation are

Correct Answer: A
Question 27 Explanation: 

For loop will execute for the i value 2,3,4,5
For i = 2, x[x[2]] = x[2]
= x[3] = 3 // since x[2] = 3
The array elements representation are

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!