Skip to main content
Q.1. What is the purpose of the return statement in a function ?
A. To print values
B. To take input from the user
C. To stop function execution and optionally pass back a result ✅
D. To define a function
❖ The return statement stops function execution and optionally passes back a result to the caller.
❖ The primary purpose of a return statement is to terminate the execution of a function and send a
specific value back to the code that called it.
❖ It effectively hands data and program control back to the caller, allowing the output of that function to be reused or
stored.
★ Computer Science - 2020
Q.2. What is the output of following program?
int x = 5;
if (x > 10)
printf("A");
else
printf("B");
★ Hexaware - 2025
A. B ✅
B. AB
C. A
D. None of these
The condition `x > 10` is false because x is 5. The else block
will be executed, and "B" will be printed.
Q.3. How many times will the following loop run ?
int i;
for(i=0; i<5; i++);
A. 0 times
B. 5 times ✅
C. 6 times
D. 7 times
❖ The loop starts at i=0 and runs until i<5. It will run for i=0,1,2,3,4, which is a total of
5 times.
★ Hexaware - 2023
Q.4. What will be the output of the following?
main ( )
{
int a = 'A';
printf ("%d", a);
}
★ UPLT - 2018
A. A
B. 65 ✅
C. a
D. Compilation errors
❖ In C, character literals like 'A' are stored as their corresponding ASCII
integer values. The ASCII value for uppercase 'A' is 65. When this value
is assigned to an integer variable a and printed using the %d format
specifier in printf, it outputs the numeric value 65.
Q.5. When a language has the capability to create new data
types, it is called as ____. ?
A. overloaded
B. extensible ✅
C. reprehensible
D. encapsulated
❖ When a language can create new data types, it is called extensible (or extensible data types / user-defined
types).
❖ Extensibility in Programming
1. User-defined types: Lets you build custom structures like classes or structs.
2. Flexibility: Helps you model real-world things in your code.
3. Clean design: Keeps code organized and easy to read.
★ UGC NET - 2017
Q.6. The range of short int data type in ‘C’ is __________. ?
A. – 32768 to + 32767 ✅
B. – 65535 to + 65535
C. – 32768 to 0
D. 0 to 32768
❖ In C, the short int data type is typically 16 bits wide. By default, it is signed, meaning its range
is from -32768 to +32767.
★ UPLT - 2026
Q.7. What is the output of following program?
# include
void fun(int x)
{
x = 30;
}
int main()
{
int y = 20;
fun(y);
printf("%d", y);
return 0;
}
★ Computer Science - 2023
A. Compile error
B. 20✅
C. Runtime error
D. 30
❖ In the given code, the variable y in main() has a value of 20. When fun(y) is called, the
value 20 is copied into the parameter x of the function fun(). Inside fun(), x is changed
to 30, but this change only affects the local copy. The original variable y in main()
remains unchanged.
❖ Therefore, when printf("%d", y) is executed, it prints the original value of y, which is 20.
Q.8. What is the output of following program?
# include
int fun(int n)
{
Int i, j, sum= 0;
for(i=1 ;i<=n; i++)
for(j=i; j<=i; j++)
sum= sum+j;
return (sum);
}
Int main()
{
printf(“%d”, fun(15));
getchar();
Return 0;
}
★ Accenture - 2024
A. 60
B. 120✅
C. 180
D. None of these
The program uses nested for loops inside the fun function. Here is exactly how it computes the result
step-by-step:
❖ Outer Loop (i): Iterates from 1 up to n (which is 15).
❖ Inner Loop (j): Starts at j = i and runs as long as j <= i. Because j increments by 1
(j++) at the end of each turn, this loop always satisfies the condition exactly once for every
value of i.
❖ Summation: Since the inner loop executes only once per outer iteration, it simply adds the
current value of i to the sum variable during each pass (sum = sum + i).
Q.9. What is a unique characteristic of a do-while loop in
programming ?
A. It executes the loop body at least once before evaluating the condition. ✅
B. It behaves exactly like a while loop
C. The loop may skip executing the body entirely.
D. None of above
❖ A unique characteristic of a do-while loop is that its code block always runs at least one time before the
condition is checked. This happens because the test condition is placed at the end of the loop instead of the start.
❖ A do-while loop is distinct from other iteration structures because it guarantees that the code block inside the loop will
execute at least one time.
❖ This happens because the condition is evaluated only after the body has run, rather than before. In contrast, a standard
while loop checks the condition first; if it is initially false, the body never executes.
★ Computer Science - 2025
Q.10. The structure or format of data is called — ?
A. Syntax ✅
B. Semantics
C. Structure
D. Protocol
❖ The structure or format of data is called Syntax. In data communication, syntax refers to the
arrangement of data blocks, specifying how data is presented or read (e.g., the first 8 bits represent
the sender's address).
❖ Note: According to standard networking textbooks (like Forouzan), Syntax is the correct definitions
for data format.
★ Bihar STET - 2019
PYQ - 5 | Comprehensive C Programming Concepts and Quiz Questions Explained