Correct Output : mmmm aaaa nnnn s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].
💡Key Conceptual Anchor:C Miscellaneous
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { float me = 1.1; double you = 1.1; if(me==you) printf("I hate Examveda"); else printf("I love Examveda"); }
Correct Answer: Option B — I love Examveda
Detailed Academic Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double. Rule of Thumb: Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .
💡Key Conceptual Anchor:C Miscellaneous
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { static int var = 5; printf("%d ", var--); if(var) main(); }
Correct Answer: Option B — 5 4 3 2 1
Detailed Academic Explanation:
When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.
The sizeof () operator gives the number of bytes taken by its operand. P is a character pointer, which needs one byte for storing its value (a character). Hence sizeof ( *p ) gives a value of 1. Since it needs two bytes to store the address of the character pointer sizeof ( p ) gives 2.
💡Key Conceptual Anchor:C Miscellaneous
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine the Final Output: void main() { printf("\nab"); printf("\bsi"); printf("\rha"); }
Correct Answer: Option D — hai
Detailed Academic Explanation:
\n - newline - printf ( " \n ab " ) ; - Prints ab \b - backspace - printf ( " \b si " ) ; - firstly ' \b ' removes 'b' from 'ab ' and then prints 'si'. So after execution of printf
💡Key Conceptual Anchor:C Miscellaneous
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: #define int char void main() { int i = 65; printf("sizeof(i)=%d", sizeof(i)); }
Correct Answer: Option B — sizeof(i)=1
Detailed Academic Explanation:
Since the #define replaces the string int by the macro char .
💡Key Conceptual Anchor:C Miscellaneous
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i=3; switch(i) { default: printf("zero"); case 1: printf("one"); break; case 2: printf("two"); break; case 3: printf("three"); break; } }
Correct Answer: Option B — three
Detailed Academic Explanation:
The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.
Type mismatch in redeclaration of function display. In third line, when the function display is encountered, the compiler doesn't know anything about the function display. It assumes the arguments and return types to be integers, (which is the default type). When it sees the actual function display, the arguments and type contradicts with what it has assumed previously. Hence a compile time error occurs.
The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result. See the picture below
💡Key Conceptual Anchor:C Miscellaneous
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: #define square(x) x*x void main() { int i; i = 64/square(4); printf("%d", i); }
Correct Answer: Option B — 64
Detailed Academic Explanation:
The macro call square(4) will substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64
++*p++ will be parse in the given order : 1. *p that is value at the location currently pointed by p will be taken 2. ++*p the retrieved value will be incremented 3. when ; is encountered the location will be incremented that is p++ will be executed.
💡Key Conceptual Anchor:C Miscellaneous
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: #include<stdio.h> #define a 10 void main() { #define a 50 printf("%d", a); }
Correct Answer: Option A — 50
Detailed Academic Explanation:
The preprocessor directives can be redefined anywhere in the program. So the most recently assigned value will be taken.
Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs. The input program to compiler looks like this : void main () { 100; printf ( " %d ", 100 ) ; } Note: 100; is an executable statement but with no action. So it doesn't give any problem.
Correct Answer: Option C — Some address will be printed
Detailed Academic Explanation:
Function names are just addresses (just like array names are addresses). main () is also a function. So the address of function main will be printed. %p in printf () specifies that the argument is an address. They are printed as hexadecimal numbers.
* is a dereference operator & is a reference operator. They can be applied any number of times provided it is meaningful. Here p points to the first character in the string "Hello". *p dereferences it and so its value is H. Again & references it to an address and * dereferences it to the value H.
Compiler error: Undefined label 'here' in function main Labels have functions scope, in other words The scope of the labels is limited to functions. The label 'here' is available in function fun() Hence it is not visible in function main.
💡Key Conceptual Anchor:C Miscellaneous
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i=1, j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Correct Answer: Option C — Compiler Error
Detailed Academic Explanation:
Compiler Error: Constant expression required in function main. The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error). Note: Enumerated types can be used in case statements.
💡Key Conceptual Anchor:C Miscellaneous
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i; printf("%d", scanf("%d", &i)); // value 10 is given as input here }
Correct Answer: Option B — 1
Detailed Academic Explanation:
scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1.
Before entering into the for loop checking condition is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop).
💡Key Conceptual Anchor:C Miscellaneous
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { struct xx { int x=3; char name[] = "hello"; }; struct xx *s = malloc(sizeof(struct xx)); printf("%d", s->x); printf("%s", s->name); }
Correct Answer: Option B — Compiler Error
Detailed Academic Explanation:
Initialization should not be done for structure members inside the structure declaration.
Linker error: undefined symbol '_i'. Explanation: extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find any error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.
💡Key Conceptual Anchor:C Miscellaneous
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i=0, j=0; if(i && j++) printf("%d..%d", i++, j); printf("%d..%d", i, j); }
Correct Answer: Option C — 0..0
Detailed Academic Explanation:
The value of i is 0. Since this information is enough to determine the truth value of the boolean expression. So the statement following the if statement is not executed. The values of i and j remains unchanged and get printed.
The variable "i" is declared as static, hence memory for I will be allocated for only once, as it encounters the statement. The function main () will be called recursively unless I becomes equal to 0, and since main () is recursively called, so the value of static I ie., 0 will be printed every time the control is returned.
💡Key Conceptual Anchor:C Miscellaneous
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i=-1, j=-1, k=0, l=2, m; m = i++ && j++ && k++ || l++; printf("%d %d %d %d %d", i, j, k, l, m); }
Correct Answer: Option C — 0 0 1 3 1
Detailed Academic Explanation:
Logical operations always give a result of 1 or 0 . And also the logical AND (&&) operator has higher priority over the logical OR (||) operator. So the expression 'i++ && j++ && k++' is executed first. The result of this expression is 0 (-1 && -1 && 0 = 0). Now the expression is 0 || 2 which evaluates to 1 (because OR operator always gives 1 except for '0 || 0' combination- for which it gives 0). So the value of m is 1. The values of other variables are also incremented by 1.
💡Key Conceptual Anchor:C Miscellaneous
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i = -1; +i; printf("i = %d, +i = %d", i, +i); }
Correct Answer: Option C — i = -1, +i = -1
Detailed Academic Explanation:
Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just because it has no effect in the expressions (hence the name dummy operator).
In first sizeof, str1 is a character pointer so it gives you the size of the pointer variable. In second sizeof the name str2 indicates the name of the array whose size is 5 (including the '\0' termination character). The third sizeof is similar to the second one.
! is a logical operator. In C the value 0 is considered to be the boolean value FALSE, and any non-zero value is considered to be the boolean value TRUE. Here 2 is a non-zero value so TRUE. !TRUE is FALSE (0) so it prints 0.
If you declare i as register compiler will treat it as ordinary integer and it will take integer value. i value may be stored either in register or in memory.
Determine Output: void main() { int i = abc(10); printf("%d", --i); } int abc(int i) { return(i++); }
Correct Answer: Option B — 9
Detailed Academic Explanation:
" return ( i++ ) ", it will first return i and then increment it. i.e. 10 will be returned.
💡Key Conceptual Anchor:C Miscellaneous
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { char a[]="12345"; int i = strlen(a); printf("%d", ++i); }
Correct Answer: Option B — 6
Detailed Academic Explanation:
The char array 'a' will hold the initialized string, whose length will be counted from 0 till the null character. Hence the 'i' will hold the value equal to 5, after the pre-increment in the printf statement, then 6 will be printed.
💡Key Conceptual Anchor:C Miscellaneous
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i; char a[]="�"; if(printf("%sn", a)) printf("Ok here n"); else printf("Forget itn"); }
Correct Answer: Option A — Ok here
Detailed Academic Explanation:
Printf will return how many characters does it print. Hence printing a null character returns 1 which makes the if statement true, thus "Ok here" is printed.
💡Key Conceptual Anchor:C Miscellaneous
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { int i=i++, j=j++, k=k++; printf("%d %d %d", i, j, k); }
Correct Answer: Option C — garbage values
Detailed Academic Explanation:
An identifier is available to use in program code from the point of its declaration. So expressions such as i = i++ are valid statements. The i, j and k are automatic variables and so they contain some garbage value.
💡Key Conceptual Anchor:C Miscellaneous
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine Output: void main() { static int i=i++, j=j++, k=k++; printf("%d %d %d", i, j, k); }
Correct Answer: Option A — 1 1 1
Detailed Academic Explanation:
Since static variables are initialized to zero by default.
Due to the assignment p[1] = 'c' the string becomes, " %c \n ". Since this string becomes the format string for printf and ASCII value of 65 is 'A', the same gets printed.
Initially pointer c is assigned to both p and q. In the first loop, since only q is incremented and not c , the value 2 will be printed 5 times. In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed.
Compiler error: lvalue required Error is in line with statement a++. The operand must be an lvalue and may be of any of scalar type for any operator, array name only when subscripted is an lvalue. Simply array name is a non-modifiable lvalue.
💡Key Conceptual Anchor:C Miscellaneous
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.