Tap an option to check your answer — the correct answer and full explanation appear after you choose.
ProgrammingC ProgrammingPPSCFPSCNTSID: PROG-096
What is the output of this C code? int x = 10; printf("%d", x - 4 * 2);
A2. ✓ Correct answer
B12.
C4.
D10.
✓ Correct answer: 2.
Full explanation
2. In C, multiplication is done before subtraction, so 4 * 2 is 8, and 10 minus 8 is 2. Why the others are wrong: 12. — 12 would be the result if the subtraction were done first and then multiplied, which is not how C works. 4. — 4 is not the result of 10 minus 8. 10. — 10 is the value of x, not the result of the expression.
ProgrammingC ProgrammingPPSCFPSCNTSID: PROG-101
In C programming, which function is used to read input from the keyboard?
Aprintf
Bscanf ✓ Correct answer
Cmain
Dreturn
✓ Correct answer: scanf
Full explanation
scanf. scanf reads values typed on the keyboard and stores them in variables, while printf writes output to the screen. Why the others are wrong: printf — printf prints output to the screen, it does not read input. main — main is the function where a C program starts, it does not read input. return — return sends a value back from a function, it does not read input.
ProgrammingC ProgrammingPPSCFPSCNTSID: PROG-106
What does 'sizeof' do in C programming?
AThe value stored in a variable.
BThe number of characters in a string.
CThe size of a variable or type in bytes. ✓ Correct answer
DThe address of a variable.
✓ Correct answer: The size of a variable or type in bytes.
Full explanation
The sizeof operator returns the size of a variable or type in bytes. Why the others are wrong: The value stored in a variable. — the value is read by using the variable’s name, not by sizeof. The number of characters in a string. — the length of a string is found with strlen, not with sizeof. The address of a variable. — the address is found with the & operator, not with sizeof.
ProgrammingC ProgrammingPPSCFPSCNTSID: PROG-111
In C, which symbol starts a single-line comment?
A#
B// ✓ Correct answer
C<!-- -->
D/* */
✓ Correct answer: //
Full explanation
//. In C, a single-line comment starts with two forward slashes, and the rest of the line is ignored by the compiler. Why the others are wrong: # — in C, # starts a preprocessor directive, not a comment. <!-- --> — this is the comment style of HTML, not C. /* */ — this starts a multi-line comment in C, not a single-line comment.
ProgrammingC ProgrammingPPSCFPSCNTSID: PROG-116
What is the output of this C code? int a = 3; a += 4; printf("%d", a);
A4
B3
C12
D7 ✓ Correct answer
✓ Correct answer: 7
Full explanation
The correct answer is 7. The statement a += 4 adds 4 to the value of a, so a becomes 3 + 4, which is 7. Why the others are wrong: 4 — 4 is only the amount added, not the final value of a. 3 — 3 is the starting value of a before 4 is added. 12 — 12 would be 3 multiplied by 4, but the code adds, not multiplies.
ProgrammingC ProgrammingBPSCID: BPP-894
Which type of pointer can store the address of any data type?
Afloat*
Bint*
Cvoid* ✓ Correct answer
DNone of these
✓ Correct answer: void*
Full explanation
void*. A void* pointer is a generic pointer that can store the address of any data type; it must be typecast to the appropriate pointer type before dereferencing.
ProgrammingC ProgrammingBPSCID: BPP-895
Which operator is used to access the value at a pointer's address?
A[]
B* ✓ Correct answer
C&
DNone of these
✓ Correct answer: *
Full explanation
*. The * operator, called the dereference operator, is used to access the value stored at a pointer's address; & gives the address of a variable.
ProgrammingC ProgrammingBPSCID: BPP-896
Where is dynamically allocated memory stored?
AArray
BStack
CHeap ✓ Correct answer
DNone of these
✓ Correct answer: Heap
Full explanation
Heap. Dynamically allocated memory (via malloc or new) is stored in the heap segment and persists until it is explicitly deallocated, unlike stack memory.
ProgrammingC ProgrammingBPSCID: BPP-897
Stack memory stores which of the following when a function is called _____?
AReturn addresses
BLocal variables
CParameters
DAll of them ✓ Correct answer
✓ Correct answer: All of them
Full explanation
All of them. When a function is called, the stack stores its return address, its local variables and its parameters, so execution can resume correctly when the function returns.
ProgrammingC ProgrammingBPSCID: BPP-898
Most convenient loop to use when working with 2D arrays?
ADo while
BFor ✓ Correct answer
CWhile
DAll of them
✓ Correct answer: For
Full explanation
For. Nested for loops are the most convenient way to iterate over the rows and columns of a 2D array, since the sizes are known in advance and indexing is clear.
ProgrammingC ProgrammingBPSCID: BPP-899
When the number of iterations are not known in advance which loop is most suitable?
ADo while
BFor
CWhile ✓ Correct answer
DAll of them
✓ Correct answer: While
Full explanation
While. A while loop is most suitable when the number of iterations is not known in advance, because it repeats only while a condition holds true.
ProgrammingC ProgrammingBPSCID: BPP-900
Which branching statement can easily handle complicated nested decisions?
ASwitch ✓ Correct answer
BIf else
CElse if
DAll of them
✓ Correct answer: Switch
Full explanation
Switch. A switch statement handles many discrete values of a single variable more clearly than deeply nested if-else chains, improving readability in complicated decisions.
ProgrammingC ProgrammingBPSCID: BPP-901
Which of the following is not a standard builtin data type in C? Bool, Long, Int, Char
ABool ✓ Correct answer
BLong
CInt
DChar
✓ Correct answer: Bool
Full explanation
Bool. Standard C before C99 had no built-in bool type; C99 introduced _Bool, with bool available through <stdbool.h>. int, long and char are standard primitive data types in C.
ProgrammingC ProgrammingBPSCID: BPP-903
Data type int occupies 4 bytes in memory, writing unsigned before int increases its ______?
ARange ✓ Correct answer
BSize
CBoth A and B
DNone of them
✓ Correct answer: Range
Full explanation
Range. Writing unsigned before int increases its range: it shifts from -2^31 to 2^31-1 to 0 to 2^32-1, since no values are spent on negatives, while the size stays 4 bytes.
ProgrammingC ProgrammingETEAID: LTP-5790
A program that combines object files and library files to generate a single executable file is called?
AEditor
BCompiler
CLinker ✓ Correct answer
DNone of these
✓ Correct answer: Linker
Full explanation
Linker. A linker combines object files and library files to generate a single executable file.
ProgrammingC ProgrammingETEAID: LTP-5798
In flowchart, a diamond sign indicates a _____?
ADisplay
BNone of these
CProcess
DDecision ✓ Correct answer
✓ Correct answer: Decision
Full explanation
Decision. In a flowchart, a diamond shape indicates a decision point.
ProgrammingC ProgrammingETEAID: LTP-5817
The halting problem is a decision problem related to program ______?
ACompilation
BTermination ✓ Correct answer
CDebugging
DNone of these
✓ Correct answer: Termination
Full explanation
Termination. The halting problem asks whether a program will terminate or run forever.
ProgrammingC ProgrammingETEAID: LTP-5819
In a flowchart, a parallelogram represents _____ operations.
ADecision
BProcess
CInput/Output ✓ Correct answer
DNone of these
✓ Correct answer: Input/Output
Full explanation
Input/Output. In a flowchart, a parallelogram represents input or output operations.
ProgrammingC ProgrammingETEAID: LTP-5823
In Scratch programming, an event is an action that the program ____ to.
ADeletes
BNone of these
CStops
DResponds ✓ Correct answer
✓ Correct answer: Responds
Full explanation
Responds. In Scratch, an event is an action that the program responds to.
ProgrammingC ProgrammingETEAID: LTP-5857
Which statement is the opposite of the break statement and is also known as the bypass statement?
AExit
BContinue ✓ Correct answer
CReturn
DNone of these
✓ Correct answer: Continue
Full explanation
Continue. The continue statement is the opposite of break and is also known as the bypass statement.