Algorithms
November 12, 2024NTA UGC NET Dec 2023 Paper-2
November 13, 2024UGC 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);
for(int i=1; i≤5; i=i+½)
printf(“%d,”,i);
It prints 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, and stops | |
It prints 1, 2, 3, 4, 5, and stops | |
It prints 1, 2, 3, 4, 5, and repeats forever | |
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.
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.
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.
Subscribe
Login
0 Comments