Qus : 2
AMU MCA PYQ
2
Predict the output of the following program:
int main()
{
int arr[5];
// Assume base address of arr is 2000 and size of integer is 32 bit
arr++;
printf("%u", arr);
return 0;
}
1
2002 2
2004 3
2020 4
value required Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2020 PYQ
Solution Array name arr represents base address.
Size of int = 32 bit = 4 bytes.
Base address = 2000.
After arr++, pointer moves by one integer = 4 bytes.
New address = 2000 + 4 = 2004.
Qus : 3
AMU MCA PYQ
2
What is the similarity between a structure, union and enumeration?
1
All of them let you define new values 2
All of them let you define new data types
3
All of them let you define new pointers 4
All of them let you define new structures Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2025 PYQ
Solution struct, union and enum are all user-defined data types in C.
Qus : 4
AMU MCA PYQ
3
In the following program, how many times “for” loop will be executed?
#include <stdio.h>
int main()
{
int i = 59, j = 10;
for( ; j ; i )
printf("%d", i);
}
1
59 times 2
10 times 3
Infinite times 4
Compiler error Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2022 PYQ
Solution Loop condition is j, which is non-zero and never changes.
Hence the loop runs infinitely.
Qus : 6
AMU MCA PYQ
4
In the following program, how many times ‘for’ loop will be executed?
#include <stdio.h>
void main()
{
int i = 5;
for (;;)
printf("%d", i);
}
1
59 times 2
10 times 3
20 times 4
Infinite times Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2025 PYQ
Solution The loop condition is for(;;) which has no condition and no termination statement. Hence the loop never stops.
Qus : 7
AMU MCA PYQ
4
What is the output for the program given below?
#include <stdio.h>
void main()
{
int i = 5;
for (; i < 12; i++);
printf("%d", i);
}
1
5 6 7 8 9 10 11 2
5 6 7 8 9 10 12 3
5 6 7 8 9 4
12 Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2025 PYQ
Solution The semicolon ; after the for loop makes it an empty loop.
The loop increments i until $i = 12$.
After the loop ends, printf prints the final value of i.
Qus : 8
AMU MCA PYQ
1
What is the output of the program given below?
#include <stdio.h>
void main()
{
int i = 500, j = 1000, k = 100;
if (j == 1000 && i > 400)
k = (j == 1000 && i > 499);
printf("k=%d", k);
else
printf("k=%d", k);
}
1
k = 1 2
k = 100 3
k = 499 4
k = 1499 Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2022 PYQ
Solution Condition j==1000 && i>400 is true, so if part executes.
Inside: (j==1000 && i>499) → both true → value 1 assigned to k.
Output is k=1.
Qus : 9
AMU MCA PYQ
2
What is the output of the following program?
#include
int main()
{
int i = 100, j = 300, k;
j = i ^ j;
i = i ^ j;
j = i ^ j;
printf("The values of i and j are %d, %d", i, j);
return 0;
}
1
100, 300 2
300 , 100 3
100, 328 4
328, 300 Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2022 PYQ
Solution This is the XOR swap technique.
After execution, values of i and j are swapped.
So output is 300, 100.
Qus : 10
AMU MCA PYQ
2
Suppose that in a C program snippet, following statements are used:
i) sizeof(int)
ii) sizeof(int*)
iii) sizeof(int**) Assuming size of pointer is 4 bytes and size of int is also 4 bytes, pick the most correct answer.
1
Only (i) would compile successfully and it would return size as 4 2
(i), (ii) and (iii) would compile successfully and size of each would be same i.e. 4 3
(i), (ii) and (iii) would compile successfully but the size of each would be different 4
(ii) and (iii) would result in compile error but (i) would compile and result in size as 4 Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2025 PYQ
Solution Given that size of int = 4 bytes and size of pointer = 4 bytes,
sizeof(int) = sizeof(int*) = sizeof(int**) = 4 bytes.
Qus : 11
AMU MCA PYQ
3
What is the purpose of the following C-function?
void str_function(char *s1)
{
char *p1, *p2, t1;
p1 = s1;
p2 = s1;
while (*p2 != '\0')
p2++;
p2--;
while (p1 < p2)
{
t1 = *p1;
*p1 = *p2;
*p2 = t1;
p1++;
p2--;
}
}
1
Extracting a substring from middle 2
Extracting a substring from left 3
Reversing a string 4
Appending a string to another string Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2022 PYQ
Solution Pointers move from start and end and swap characters until they meet ⇒ string is reversed.
Qus : 14
AMU MCA PYQ
3
What will be the output of the following program?
int main()
{
int *p, a = 12;
p = &a;
*p += 1;
printf("12,");
--*p;
printf("%d, %d\n", *p, a);
return 0;
}
1
Error 2
12 3
12, 12, , 13 4
12, 13, 13 Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2022 PYQ
Solution a=12 → *p+=1 makes a=13.
Then --*p makes a=12.
Printed output becomes 12,12,12.
Qus : 15
AMU MCA PYQ
1
Consider the array definition
int num[10] = {3, 3, 3};
Pick the correct answer:
1
num[9] is the last element of the array num 2
The value of num[8] is 5 3
The value of num[3] is 3 4
None of these Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2025 PYQ
Solution Array size is 10, so valid indices are 0 to 9.
Hence num[9] is the last element.
Uninitialized elements are set to 0.
Qus : 19
AMU MCA PYQ
3
What is the output for the program given below?
#include <stdio.h>
int main()
{
char i = 2;
switch(i)
{
case '1':
printf("Black\n");
case '2':
printf("White\n");
default:
printf("Red\n");
}
printf("Blue");
return 0;
}
1
Black
Blue 2
White
Blue 3
Red
Blue 4
Black
White
Blue Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2022 PYQ
Solution Solution:
i = 2 (numeric), but case '2' is character constant with ASCII value 50
No case matches, so default executes → prints Red
After switch, printf("Blue") always runs
Qus : 23
AMU MCA PYQ
3
In C++, a variable defined within a block is visible
1
from the point of definition onward in the program 2
from the point of definition onward in the function 3
from the point of definition onward in the block 4
throughout the function Go to Discussion
AMU MCA Previous Year PYQ
AMU MCA AMU MCA 2021 PYQ
Solution Block scope variable is visible only inside that block from its declaration onward.
[{"qus_id":"16735","year":"2025"},{"qus_id":"16744","year":"2025"},{"qus_id":"16745","year":"2025"},{"qus_id":"16751","year":"2025"},{"qus_id":"16770","year":"2025"},{"qus_id":"16771","year":"2025"},{"qus_id":"16773","year":"2025"},{"qus_id":"16774","year":"2025"},{"qus_id":"16780","year":"2025"},{"qus_id":"16994","year":"2022"},{"qus_id":"16997","year":"2022"},{"qus_id":"17001","year":"2022"},{"qus_id":"17006","year":"2022"},{"qus_id":"17011","year":"2022"},{"qus_id":"17020","year":"2022"},{"qus_id":"17026","year":"2022"},{"qus_id":"17036","year":"2022"},{"qus_id":"17044","year":"2021"},{"qus_id":"17050","year":"2021"},{"qus_id":"17051","year":"2021"},{"qus_id":"17056","year":"2021"},{"qus_id":"17204","year":"2020"},{"qus_id":"17207","year":"2020"}]