...
Algorithms
November 12, 2024
NTA UGC NET Dec 2023 Paper-2
November 13, 2024
Algorithms
November 12, 2024
NTA UGC NET Dec 2023 Paper-2
November 13, 2024

UGC NET CS 2008-june-Paper-2

Question 11
What is the effect of the following C code ?
for(int i=1; i≤5; i=i+½)
         printf(“%d,”,i);
A
It prints 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, and stops
B
It prints 1, 2, 3, 4, 5, and stops
C
It prints 1, 2, 3, 4, 5, and repeats forever
D
It prints 1, 1, 1, 1, 1, and repeats forever
Question 11 Explanation: 
According to integer datatype, fraction values we are not considering. So,it will always become
1.
Iteration-1: for(int i=1; i≤5; i=i+½) /*condition TRUE, then we are printing value but incrementing by 0. It means, i=1+0 */
So, ‘i’ value always become 1 only. The given condition always TRUE and will print infinite times.
Correct Answer: D
Question 11 Explanation: 
According to integer datatype, fraction values we are not considering. So,it will always become
1.
Iteration-1: for(int i=1; i≤5; i=i+½) /*condition TRUE, then we are printing value but incrementing by 0. It means, i=1+0 */
So, ‘i’ value always become 1 only. The given condition always TRUE and will print infinite times.
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!!