AMCAT C Input Output Snippets

AMCAT 





                           

1)enum names{AMAR,AKBAR,ANTONY}
function main()
{
print AMAR
print AKBAR
print ANTONY
}
what is the o/p
a)000
b)111 
c)102 
d)123

ans:d

2)function main()
{
static integer abc=5
print abc--
if(abc)
main()//calling main function
}

ans: 54321

3)To implement virtual functions.What should be used?
a) dynamic dispatching
b) static dispatching
c) static binding
d) anonymous classes

ans: (d)

4)What is the term given to the variable whose scope is beyond all the scopes i.e., it can be accessed by all the scopes? 
option a: Universal Variable 
option b: Global Variable 
option c:External Variable 
option d: Auto Variable 
option e: Both 2 and 3 

ans: (b)

5)-------------returns a value unlike -------------------
option a:Procedure. Subroutine 
option b:Procedure. function
option c:Function. Method 
option d:Function, Procedure 
ans:(d)

6) X want to place elements of an array in heap form.on which floor of the heap will he place 6th element of array
ans:3rd

7) Which is used to convert source code to target language
a) linker
b) compiler 
c) executer
d) loader
ans:(b)

7)value of key is 85,hash table size is 12.Find index of an empty hash table when linear probing is used
ans:1

In linear probing------index value is given by----85%12------->1
so index =1

8) Function Display(string mystr)//statement 1
{
print "hello my name is"
print mystr //statement 2
}
function main() //statement 3
{
string str = "mr.beans"
integer num = display(str) // statement 4
}
option:
a)statement 1 error
b)statement 2 error
c)statement 3 error
d)statement 4 error
Answer: 4 

9) Q4. Pankaj makes a program to print the product of cubes of the first 10 whole numbers. he writes the following program:

integer x = 0 // statement 1
integer sum = 0 // statement 2
while ( x < 10 ) // statement 3
{
sum = x*x*x // statement 4
x = x + 1 // statement 5
}
print sum // statement 6

Is her program correct? If not, which statement will you modify to correct it?


1) No error, the program is correct

2) Statement 1
3) Statement 4
4) Statement 6
5) Statement 2

Answer : 1


10) Max no.of comparisions in binary search


a) n
b) (n+1)/2
c) log(n)+1
d) 2^log(n)
ans:(c)

11) What will be the output of the following pseudo-code statements: 
integer a = 984, b=10
//float is a data-type to store real numbers. 
float c
c = a / b
print c

Answer :98.4

12) Function MyFunc1(integer n)
{
return n*2
}
function MyFunc2(integer n)
{
print "The value is " n
}
Which of the given two functions can be categorized as procedure?

1. MyFunc1
2. MyFunc2
3. Both MyFunc1 and MyFun2
4. a function cannot be a procedure.

Answer :2

13) Function main()
{
automatic variable var
print var
}
output:

1. 0
2. 1
3. Garbage value
4. This code will generate a compile time error.

Answer :4

14) Function Display(string mystr)//statement 1
{
print "hello my name is"
print mystr //statement 2
}
function main() //statement 3
{
string str = "mr.beans"
integer num = display(str) // statement 4
}
option:

a)statement 1 error
b)statement 2 error
c)statement 3 error
d)statement 4 error


Answer: 4 









No comments:

Post a Comment