AMCAT Previous Years Questions on Miscellaneous : Procedure, functions and scope

Topics
Sub- Topics
Expected Questions
Basic Programming
10 – 12 Questions
Data Structures
6 – 8 Questions
OOPs
4 – 6 Questions
Miscellaneous
4 – 5 Questions

Question 1
The default parameter passing mechanism is
A. call by value
B. call by reference
C. call by value-result
D. None of these.



Correct Answer: A

Question 2
Determine output:
main()
{
int i = 5;
printf(“%d%d%d%d%d”, i++, i–, ++i, –i, i);
}

A. 5454
B. 45445
C. 54554
D. 45545

Correct Answer: D


Question 3
What will be printed when this program is executed?
int f(int x)
{
if(x <= 4)
return x;
return f(–x);
}
void main()
{
printf(“%d “, f(7));
}
A. 4 5 6 7
B. 1 2 3 4
C. 4
D. Syntax error
E. Runtime error



Correct Answer: C
In this recursive function call the function will return to main caller when the value of x is 4. Hence the output.

Question 4
Which of the following function calculates the square of ‘x’ in C?
A. sqr(x)
B. power(x, 2)
C. power(2, x)
D. pow(x, 2)
E. pow(2, x)



Correct Answer: B

Question 5
char* myfunc(char *ptr) { ptr+=3; return(ptr); } void main() { char *x, *y; x = “PrepInsta”; y = myfunc(x); printf(“y=%s”, y); } What will be printed when the sample code above is executed?
A. y=PrepInsta
B. y=pInsta
C. y=Insta
D. y=nsta
E. y=epInsta

Correct Answer: C


Question 6
#include <stdio.h>
extern int var;
int main()
{
var = 10;
printf(“%d “, var);
return 0;
}
A. 20
B. 0
C. compiler error



Correct Answer: C
extern only defines it but allocates no memory so compiler error.