Consider the following ANSI-C program.
#include <stdio.h>
int main(){
int *ptr, a, b, c;
a=5; b=11; c=20;
ptr=&a; *ptr=c; ptr=&c;
a=*(&b); c=*ptr-a;
printf("%d",c);
return(0);
}
The output of this program is ____________. (answer in integer)
Note: Assume that the program compiles and runs successfully.
An alternative way to solve this is to maintain a small table of variable values after every statement, instead of purely symbolic substitution.
Step 1: Initialization
After the declarations and first assignment line, the table of values is: \(a = 5\), \(b = 11\), \(c = 20\).
Step 2: Pointer aliasing
The statement ptr = &a; makes \(ptr\) an alias for the memory cell holding \(a\). Any write through \(ptr\) now changes \(a\), and any read through \(ptr\) now reads \(a\).
Step 3: Indirect write
The statement *ptr = c; copies the value stored in \(c\) (namely 20) into the cell that \(ptr\) aliases, which is \(a\). Updated table: \(a = 20\), \(b = 11\), \(c = 20\).
Step 4: Re-aliasing
The statement ptr = &c; now makes \(ptr\) an alias for \(c\) instead of \(a\). The value of \(a\) that was just set (20) is not touched again by this line - it simply changes what \(ptr\) points to going forward.
Step 5: Direct assignment
The statement a = *(&b); reduces to \(a = b\), since taking the address of \(b\) and then dereferencing it just yields \(b\) itself. So \(a\) is overwritten with \(11\). Updated table: \(a = 11\), \(b = 11\), \(c = 20\).
Step 6: Final computation
The statement c = *ptr - a; reads \(*ptr\), which is the value of \(c\) since \(ptr\) now aliases \(c\). That value is still \(20\) (it was never modified after Step 3). So we compute \(c = 20 - 11 = 9\).
Step 7: Output
The final value printed is \(c = 9\), which matches the official key of 9.
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:

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).
What is printed by the following ANSI C program?
#include<stdio.h>
int main(int argc, char argv[])
{
char a = 'P';
char b = 'x';
char c = (a & b) + '';
char d = (a | b) - '-';
char e = (a ^ b) + '+';
printf("%c %c %c\n", c, d, e);
return 0;
}
ASCII encoding for relevant characters is given below
