Question 5614 – UGC NET CS 2013 June-paper-2
May 20, 2024
Question 5616 – UGC NET CS 2013 June-paper-2
May 20, 2024
Question 5614 – UGC NET CS 2013 June-paper-2
May 20, 2024
Question 5616 – UGC NET CS 2013 June-paper-2
May 20, 2024

Question 5615 – UGC NET CS 2013 June-paper-2

How many times the word ‘print’ shall be printed by the following program segment ?
for (i=1, i≤2,i++)
for (j=1,j≤2,j++)
for(k=1,k≤2,k++)
printf(“print/n”)

Correct Answer: D

Question 9 Explanation: 
Iteration-1: In iteration-1 of ith loop will execute once and jth loop 2 times.
Each jth loop will execute kth loop 2 times.
Finally, iteration-1 will display 4 times of “print/n” word.
Iteration-2: In iteration-2 of ith loop will execute once and jth loop 2 times.
Each jth loop will execute kth loop 2 times.
Finally, iteration-2 will display 4 times of “print/n” word.
Above code segment will print 8 times.
Better understanding purpose given modified code segment:
#include
int main()
{
int i,j,k,jj=0,kk=0,ii=0;
for(i=1;i<=2;i++)
{
ii++;
for(j=1;j<=2;j++)
{
jj++;
for(k=1;k<=2;k++)
{
kk++;
printf(“print/n”);
}
}
}
printf(“ii=%d \t jj=%d \t kk=%d”,ii,jj,kk);
return 0;
}
Output:
print/n print/n print/n print/n print/n print/n print/n print/n
ii=2 jj=4 kk=8
A
1
B
3
C
6
D
8
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!!