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

Consider the C program given below. What does it print?

# include <stdio.h>
int main ( )
{
int i, j;
int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
for (i = 0; i < 3; i++)
{
a[i] = a[i]+1;
i++;
}
i - - ;
for (j = 7; j > 4, j- -)
{
int i = j/2;
a[i] = a[i] - 1;
}
print ("%d, %d", i, a [i]);
}

A
3, 3
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
2, 4
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
2, 3
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
3, 2
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution

The correct option is D 3, 2
Inside main function:

Note:
When any variable is not declared inside any block then it can referred to outer block for same variable.

flag
Suggest Corrections
thumbs-up
0
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Cardinality of Sets
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon