Yash Sir Sanchit Sir: Visit Our Website
Yash Sir Sanchit Sir: Visit Our Website
Download KG App
Q1. Given the following statement, what will be displayed on the screen?
1. int * aPtr;
2. *aPtr = 100;
3. cout << *aPtr + 2;
a. 100
b. 102
c. 104
d. 108
(Topic – C programming)
(Asked in Gate 2014)
Q2. Which of these will happen if recursive method does not have a base case?
A) 25
B) 5
C) 50
D) 40
a) call by value
b) call by reference
c) call by pointer
d) call by object
int main()
int k;
int k;
a) Yes
b) No
c) Depends on the compiler
d) Depends on the C standard implemented by compilers
(Topic – C programming )
(Asked in TCS 2012)
Correct Opt b a c b a
SOLUTIONS -
1. Answer: (b)
= *aPtr + 2
= 100 + 2
= 102
2. Answer: a
Explanation: If a recursive method does not have a base case then an infinite loop occurs
which results in Stack Overflow.
3. Ans: c
Explanation:
There is an array of integer arr[]={10,20,30,40,50}. There are two variables a and b
declared. .
4. Answer: b
Explanation: In the call by reference, it will just passes the reference of the memory
addresses of passed values rather than copying the value to new memories which reduces
the overall time and memory use..
5. Answer: a
Explanation: There can be blocks inside the block. But within a block, variables have only
block scope.
KGYT
on