UGC NET CS 2006 June-Paper-2

Question 11
What is the output of the following program segment ?
main ( )
{
int count, digit=0;
count=1;
while(digit <=9)
{
printf(​”%d /n”” , ++count);
++digit;
}
}
A
10
B
9
C
12
D
11
Question 11 Explanation: 
The digit starts with 0 and will run 9 more times. It means, the loop will run 10 runs. The count variable we are given pre increment. So, it increments before assigning values.
It prints the result is
2 /n 3 /n 4 /n 5 /n 6 /n 7 /n 8 /n 9 /n 10 /n 11
Correct Answer: D
Question 11 Explanation: 
The digit starts with 0 and will run 9 more times. It means, the loop will run 10 runs. The count variable we are given pre increment. So, it increments before assigning values.
It prints the result is
2 /n 3 /n 4 /n 5 /n 6 /n 7 /n 8 /n 9 /n 10 /n 11

Leave a Reply

Your email address will not be published. Required fields are marked *

error: <b>Alert: </b>Content selection is disabled!!
OOPS
May 6, 2024
Bit-Rate
May 6, 2024
OOPS
May 6, 2024
Bit-Rate
May 6, 2024