Consider the following ANSI C program.
#include <stdio.h>
int main()
{
int i, j, count;
count = 0;
i = 0;
for (j = -3; j <= 3; j++)
{
if ((j >= 0) && (i++))
count = count + j;
}
count = count + i;
printf("%d", count);
return 0;
} Which one of the following options is correct?
Step 1: Initialize variables.
Initially,
i = 0, count = 0
The loop executes for values of j from −3 to 3.
Step 2: Analyze the conditional expression.
The condition used inside the loop is:
(j ≥ 0) && (i++)
The logical AND operator (&&) follows short-circuit evaluation. Hence, the expression i++ is evaluated only when j ≥ 0 is true.
Step 3: Evaluate each loop iteration.
For j = −3, −2, −1:
j ≥ 0 is false ⇒ i++ is not executed
i = 0, count = 0
For j = 0:
j ≥ 0 is true, i++ evaluates to 0 (false)
Condition fails, but i is incremented
i = 1, count = 0
For j = 1:
i++ evaluates to 1 (true)
count = count + 1 = 1
i = 2
For j = 2:
i++ evaluates to 2 (true)
count = 1 + 2 = 3
i = 3
For j = 3:
i++ evaluates to 3 (true)
count = 3 + 3 = 6
i = 4
Step 4: Final calculation.
After exiting the loop:
count = count + i = 6 + 4 = 10
Final Conclusion:
The program compiles successfully and prints:
10
Final Answer: (B)
Suppose in a multiprogramming environment, the following C program segment is executed. A process goes into the I/O queue whenever an I/O related operation is performed. Assume that there will always be a context switch whenever a process requests an I/O, and also whenever the process returns from an I/O. The number of times the process will enter the ready queue during its lifetime (not counting the time the process enters the ready queue when it is run initially) is _________ (Answer in integer).

Arrange the following data types available in C language according to their size (smallest to largest):
A. signed long int
B. long double
C. unsigned char
D. unsigned int
Choose the correct answer from the options given below:
What is printed by the following ANSI C program?
#include<stdio.h>
int main(int argc, char argv[])
{
int a[3][3][3] = {
{1, 2, 3, 4, 5, 6, 7, 8, 9},
{10, 11, 12, 13, 14, 15, 16, 17, 18},
{19, 20, 21, 22, 23, 24, 25, 26, 27}};
int i = 0, j = 0, k = 0;
for( i = 0; i < 3; i++){
for(k = 0; k < 3; k++)
printf("%d ", a[i][j][k]);
printf("\n");
}
return 0;
}