Qus : 4
WB JECA MCA PYQ
2
Read the following statements about functions in C and choose the correct option:
(i) A function in C can return only one value directly.
(ii) Function names can be the same as variable names in the same scope.
(iii) A function must always take at least one argument.
(iv) Recursion is allowed in C functions.
1
All statements are correct. 2
Only statements (i) and (iv) are correct. 3
Only statements (ii) and (iii) are correct. 4
None of the statements are correct. Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2025 PYQ
Solution (i) true, (ii) false, (iii) false, (iv) true.
Qus : 5
WB JECA MCA PYQ
3
What happens when a recursive function in C lacks a proper base condition?
1
The function executes only once and terminates. 2
The compiler shows a syntax error. 3
It leads to infinite recursion and eventually a stack overflow. 4
The function automatically converts to an iterative form. Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2025 PYQ
Solution No base condition → infinite recursion → stack overflow.
Qus : 7
WB JECA MCA PYQ
3
Which of the following statements about structures and unions in C is true?
1
In a structure, all members share the same memory location. 2
In a union, all members have separate memory locations. 3
The size of a union is equal to the size of its largest member. 4
The size of a structure is always equal to the sum of the sizes of its members, without any padding. Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2025 PYQ
Solution Union size = size of largest member; structure uses separate memory with padding.
Qus : 8
WB JECA MCA PYQ
1
What will be the output of the following program?
#include
int main()
{
char str1[20] = "Hello ";
char str2[20] = "Hello";
strcpy(str2, str1);
if (strcmp(str1, str2) == 0)
printf("Equal
");
else
printf("Not Equal
");
return 0;
}
1
Equal 2
Not Equal 3
Compiler Error 4
Undefined Behavior Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2025 PYQ
Solution After strcpy, both strings are same → strcmp returns 0 → Equal.
Qus : 12
WB JECA MCA PYQ
1
What is the output of the following code snippet?
#include <stdio.h>
main() {
int x = 65, *p = &x;
void *q = p;
char *r = q;
printf("%c", *r);
} (A) $A$
(B) $Z$
(C) $65$
(D) None of the above
1
A 2
B 3
C 4
D Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2024 PYQ
Solution
Step 1: Initialization
$x = 65$
In ASCII, $65 \equiv A$
Step 2: Pointer flow
$p = \&x \;\; \rightarrow$ pointer to integer
$q = p \;\; \rightarrow$ void pointer
$r = q \;\; \rightarrow$ typecast to char pointer
Step 3: Dereferencing
Since r is char*, it reads 1 byte .
The value stored = $65$
Step 4: Printing
printf("%c", *r); prints character with ASCII $65$.
Hence, the output is:
$\; \boxed{A} \;$
Correct Answer: (A)
Qus : 16
WB JECA MCA PYQ
4
What is the output of the following C-program?\n#include\n#define CUBE(x) (x*x*x)\nint main() { int a, b=3; a = CUBE(b++); printf("%d, %d\n", a, b); return 0; }
1
9, 4 2
27, 4 3
27, 6 4
Error Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2024 PYQ
Solution
Solution:
- Macro expansion: CUBE(b++) → (b++ * b++ * b++).
- This causes multiple side effects → undefined behavior.
- Most compilers treat this as error/undefined .
Answer = (D) Error
Qus : 24
WB JECA MCA PYQ
3
What is the output of the following C program?
#include <stdio.h>
void main(){
int a = -7;
float b;
b = a++;
printf("%d, %f ", a, ++b);
} 1
-6, -7.000000 2
-5, -6 3
-6, -6.000000 4
-6, -6 Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution
Explanation: The statement b = a++; assigns the current value of a (−7) to b and then increments a to −6.
Later, ++b increments b from −7 to −6 before printing.
$$ a = -6,\quad b = -6.000000 $$
Qus : 25
WB JECA MCA PYQ
4
What is the output?
#include <stdio.h>
void main(){
int i = -1;
printf("sizeof(i) = %d", sizeof(i));
} 1
Compiler Error 2
sizeof(i) = -1 3
sizeof(i) = 1 4
sizeof(i) = 4 Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution
Explanation: The operator sizeof gives the size of the type in bytes, not the value.
On most 32-bit and 64-bit systems, sizeof(int) is 4.
$$ \text{Output: } \texttt{sizeof(i) = 4} $$
Qus : 26
WB JECA MCA PYQ
3
What is the output?
#include <stdio.h>
void main(){
int x = -1, y = 1, z = 0;
if(x && y++ && z)
++x, y++, --z;
printf("%d, %d, %d", x++, y++, z++);
} 1
0, 3, 0 2
Compiler Error 3
-1, 2, 0 4
1..0 Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution
Explanation: In the condition x && y++ && z, since z = 0, the logical AND short-circuits and the body of the if is not executed.
However, y++ is evaluated before the short-circuit, so y becomes 2.
Values before printing:
$$ x = -1,\ y = 2,\ z = 0 $$
So the program prints:
$$ (-1,\ 2,\ 0) $$
Qus : 27
WB JECA MCA PYQ
1
What is the output?
#include <stdio.h>
enum colors{RED, BROWN, ORANGE};
void main(){
printf("%ld..%f..%d", RED, BROWN, ORANGE);
} 1
Compiler Error 2
0..0.000000..1 3
0..1.000000..2 4
Runtime Error Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution
Explanation: The format specifiers do not match the data types (%f is used for int).
This causes undefined behavior .
The program may compile, but the output is not reliable.
Correct choice: None of these .
Qus : 30
WB JECA MCA PYQ
3
What is the output?
#include <stdio.h>
void main(){
int **ptr;
int temp = 65;
ptr[0] = &temp;
printf("%d", ptr[0][0]);
} 1
Compiler error 2
65 3
Segmentation Fault 4
Runtime Error Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution
Explanation: The pointer ptr is uninitialized, so it does not point to valid memory.
When the code tries to access ptr[0], it attempts to dereference an invalid location.
This leads to undefined behavior, and in most cases results in a segmentation fault .
Qus : 31
WB JECA MCA PYQ
2
What is the output?
#include <stdio.h>
#include <stdlib.h>
void main(){
int *ptr;
ptr = (int*) calloc(3, sizeof(int));
ptr[2] = 30;
printf("%d", *ptr);
free(ptr);
} 1
30 2
0 3
calloc 4
Error Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution
Explanation: The function calloc initializes all allocated memory blocks with zero.
So ptr[0] is initialized to 0 .
The statement *ptr is equivalent to ptr[0].
$$ \text{Output: } 0 $$
Qus : 32
WB JECA MCA PYQ
1
25.What is the output of the following program ? include <iostream> using namespace std; int addition (int a, int b) { return a+b; } double addition (double a, double b) { return a+b; } int main () { cout<< addition (35,20) << “;”; cout<< addition (34.1,12.7); return 0; }
1
55;46.8 2
Compile Error 3
Runtime Error 4
Segmentation Fault Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution The given program defines two overloaded functions `addition`:
1. `int addition(int a, int b)` → returns integer sum
2. `double addition(double a, double b)` → returns double sum
In `main()`:
- `addition(35,20)` calls the integer version → 35 + 20 = 55
- `addition(34.1,12.7)` calls the double version → 34.1 + 12.7 = 46.8
Therefore, the output is:
55;46.8
Qus : 33
WB JECA MCA PYQ
1
26.What is the output of the following program ? #include <iostream> using namespace std; template <class C1, class C2> bool is_equal (C1 var1, C2 var2) { return (var1 = = var2); } int main () { if (is_equal(10,10.0)) cout<< “Equal”; else cout<< “Not equal”; return 0; }
1
Equal 2
Not equal 3
Compile Error 4
Runtime Error Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution The function `is_equal` is a template that compares two variables of possibly different types.
In `main()`, we call `is_equal(10, 10.0)`.
- `10` is an integer (int).
- `10.0` is a double.
C++ allows implicit type conversion during comparison.
So, `10 == 10.0` evaluates to `true`.
Therefore, the condition in the `if` statement is true, and the output will be:
Equal
Qus : 34
WB JECA MCA PYQ
1
26.What is the output of the following program ?
#include <iostream>
using namespace std;
int main()
{
int var = 0;
while (var < 10)
{
cout << var << " ";
var++;
}
cout << var;
return 0;
}
1
0 1 2 3 4 5 6 7 8 9 10 2
0 1 2 3 4 5 6 7 8 9 3
1 2 3 4 5 6 7 8 9 10 4
1 2 3 4 5 6 7 8 9 Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution Output:
0 1 2 3 4 5 6 7 8 9 10
Explanation:
The variable var starts at 0.
The while (var < 10) loop prints 0 1 2 3 4 5 6 7 8 9 with spaces.
When var reaches 10, the loop stops.
After the loop, cout << var; prints 10.
Final output:
Qus : 35
WB JECA MCA PYQ
1
What is the output of the following program ?
#include <iostream>
using namespace std;
struct demo
{
int var;
};
int main()
{
demo str;
demo *ptr;
str.var = 100;
ptr = &str;
cout << ptr->var;
return 0;
}
1
100 2
Memory address of var 3
Compile Error 4
L-value Error Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution Output:
100
Explanation:
str.var = 100; assigns 100 to the structure variable.
ptr = &str; makes the pointer point to str.
ptr->var accesses the member var of structure str via pointer.
Hence it prints 100.
Qus : 36
WB JECA MCA PYQ
1
29.What is the output of the following program ?
#include <iostream>
using namespace std;
int main ()
{
int c1 = 10;
int c2 = 20;
{
int c1;
c1 = 50;
c2 = 50;
cout << "c1= " << c1 << ", c2=" << c2;
}
cout << ", c1= " << c1 << ", c2=" << c2;
return 0;
}
1
c1= 50, c2= 50; c1= 10, c2= 50 2
c1= 10, c2= 20; c1= 10, c2= 20 3
c1= 50, c2= 50; c1= 10, c2= 20 4
c1= 10, c2= 20; c1= 10, c2= 50 Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution Output:
c1= 50, c2=50, c1= 10, c2=50
Explanation:
Outer c1 = 10, c2 = 20.
Inside the inner block, a new local c1 is declared (shadowing outer c1).
Inner c1 = 50, and c2 (outer one) is updated to 50.
First cout prints → c1= 50, c2=50.
After the block ends, inner c1 is destroyed. Outer c1 remains 10, while outer c2 is 50.
Second cout prints → , c1= 10, c2=50.
? Final output: c1= 50, c2=50, c1= 10, c2=50.
Qus : 39
WB JECA MCA PYQ
2
32.What is the output of the following program ?
#include <iostream>
using namespace std;
int main()
{
int var = 2;
do
{
cout << var;
} while (var--);
return 0;
}
1
21 2
210 3
2 4
1 Go to Discussion
WB JECA MCA Previous Year PYQ
WB JECA MCA JECA MCA 2023 PYQ
Solution Explanation:
Initially var = 2.
First iteration: prints 2, then var-- makes var = 1.
Second iteration: prints 1, then var-- makes var = 0.
Third iteration: prints 0, then var-- makes var = -1. Condition fails and loop exits.
So output is:
[{"qus_id":"12632","year":"2024"},{"qus_id":"12644","year":"2024"},{"qus_id":"12645","year":"2024"},{"qus_id":"12646","year":"2024"},{"qus_id":"12649","year":"2024"},{"qus_id":"12653","year":"2024"},{"qus_id":"12657","year":"2024"},{"qus_id":"12660","year":"2024"},{"qus_id":"12663","year":"2024"},{"qus_id":"12668","year":"2024"},{"qus_id":"12671","year":"2024"},{"qus_id":"12756","year":"2023"},{"qus_id":"12757","year":"2023"},{"qus_id":"12758","year":"2023"},{"qus_id":"12759","year":"2023"},{"qus_id":"12760","year":"2023"},{"qus_id":"12761","year":"2023"},{"qus_id":"12762","year":"2023"},{"qus_id":"12763","year":"2023"},{"qus_id":"12764","year":"2023"},{"qus_id":"12780","year":"2023"},{"qus_id":"12781","year":"2023"},{"qus_id":"12782","year":"2023"},{"qus_id":"12783","year":"2023"},{"qus_id":"12784","year":"2023"},{"qus_id":"12785","year":"2023"},{"qus_id":"12786","year":"2023"},{"qus_id":"12787","year":"2023"},{"qus_id":"17674","year":"2025"},{"qus_id":"17676","year":"2025"},{"qus_id":"17675","year":"2025"},{"qus_id":"17677","year":"2025"},{"qus_id":"17678","year":"2025"},{"qus_id":"17679","year":"2025"},{"qus_id":"17684","year":"2025"},{"qus_id":"17685","year":"2025"},{"qus_id":"17687","year":"2025"},{"qus_id":"17747","year":"2025"},{"qus_id":"17750","year":"2025"}]