Amcat Papers

amcat paper


Amcat Papers



1. There is a new data-type which can take as values natural numbers between (and including) 0 and 25. How many minimum bits are required to store this data-type.
Option 1 : 4
Option 2 : 5
Option 3 : 1
Option 4 : 3

2. A data type is stored as an 6 bit signed integer. Which of the following cannot be represented by this data type?
Option 1 : -12
Option 2 : 0
Option 3 : 32
Option 4 : 18

3. A language has 28 different letters in total. Each word in the language is composed of maximum 7 letters. You want to create a data-type to store a word of this language. You decide to store the word as an array of letters. How many bits will you assign to the data-type to be able to store all kinds of words of the language.
Option 1 : 7
Option 2 : 35
Option 3 : 28
Option 4 : 196

4. A 10-bit unsigned integer has the following range:
Option 1 : 0 to 1000
Option 2 : 0 to 1024
Option 3 : 1 to 1025
Option 4 : 0 to 1023
5. Rajni wants to create a data-type for the number of books in her book case. Her shelf can accommodate a maximum of 75 books. She allocates 7 bits to the data-type. Later another shelf is added to her book-case. She realizes that she can still use the same data-type for storing the number of books in her book-case. What is the maximum possible capacity of her new added shelf?
Option 1 : 52
Option 2 : 127
Option 3 : 53
Option 4 : 75

6. A new language has 15 possible letters, 8 different kinds of punctuation marks and a blank character. Rahul wants to create two data types, first one which could store the letters of the language and a second one which could store any character in the language. The number of bits required to store these two data-types will respectively be:
Option 1 : 3 and 4
Option 2 : 4 and 3
Option 3 : 4 and 5
Option 4 : 3 and 5

7. Parul takes as input two numbers: a and b. a and b can take integer values between 0 and 255. She stores a, b and c as 1-byte data type. She writes the following code statement to process a and b and put the result in c.
c = a + 2*b
To her surprise her program gives the right output with some input values of a and b, while gives an erroneous answer for others. For which of the following inputs will it give a wrong answer?
Option 1 : a = 10 b = 200
Option 2 : a = 200 b = 10
Option 3 : a = 50 b = 100
Option 4 : a = 100 b = 50

8. Prashant takes as input 2 integer numbers, a and b, whose value can be between 0 and 127. He stores them as 7 bit numbers. He writes the following code to process these numbers to produce a third number c.
c = a - b
In how many minimum bits should Prashant store c?
Option 1 : 6 bits
Option 2 : 7 bits
Option 3 : 8 bits
Option 4 : 9 bits

9. Ankita takes as input 2 integer numbers, a and b, whose value can be between 0 and 31. He stores them as 5 bit numbers. He writes the following code to process these numbers to produce a third number c.
c = 2*(a - b)
In how many minimum bits should Ankita store c?
Option 1 : 6 bits
Option 2 : 7 bits
Option 3 : 8 bits
Option 4 : 9 bits

10. A character in new programming language is stored in 2 bytes. A string is represented as an array of characters. A word is stored as a string. Each byte in the memory has an address. The word "Mahatma Gandhi" is stored in the memory with starting address 456. The letter 'd' will be at which memory address?
Option 1 : 468
Option 2 : 480
Option 3 : 478
Option 4 : 467

11. Stuti is making a questionnaire of True-false questions. She wants to define a data-type which stores the response of the candidate for the question. What is the most-suited data type for this purpose?
Option 1 : integer
Option 2 : boolean
Option 3 : float
Option 4 : character

12. A pseudo-code is used. Assume that when two data-types are processed through an operator, the answer maintains the same data-type as the input data-types. Assume that all data-types have enough range to accommodate any number. If two different data-types are operated on, the result assumes the more expressive data-type.
What will be the output of the following pseudo-code statements:
integer a = 456,   b, c, d =10 
b = a/d
c = a - b
print c
Option 1 : 410
Option 2 : 410.4
Option 3 : 411.4
Option 4 : 411

13. A pseudo-code is used. Assume that when two data-types are processed through an operator, the answer maintains the same data-type as the input data-types. Assume that all data-types have enough range to accommodate any number. If two different data-types are operated on, the result assumes the more expressive data-type.
// in pseudo code refers to comment
What will be the output of the following pseudo-code statements:
integer a = 984,   b, c, d =10 
print remainder(a,d) // remainder when a is divided by d
a = a/d
print remainder(a,d) // remainder when a is divided by d
Option 1 : 48
Option 2 : Error
Option 3 : 84
Option 4 : 44

14. Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.)
*   /  
+   -
AND
OR
For operators with equal precedence, the precedence is from left-to-right in expression.
What will be the output of the following code statements?

integer a = 50, b = 25, c = 0
print ( a > 45 OR b > 50 AND c > 10 )
Option 1 : 1
Option 2 : 0
Option 3 : -1
Option 4 : 10

15. Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.)
*   /  
+   -
AND
OR
For operators with equal precedence, the precedence is from left-to-right in expression.
What will be the output of the following code statements?
integer a = 50, b = 25, c = 5
print a * b / c + c
Option 1 : 120
Option 2 : 125
Option 3 : 255
Option 4 : 250

16. Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.) *   /  +   - AND OR
For operators with equal precedence, the precedence is from left-to-right in expression.
What will be the output of the following code statements?
integer a = 10, b = 35, c = 5
print a * b / c - c
Option 1 : 65
Option 2 : 60
Option 3 : Error
Option 4 : 70

17. Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.)
*   /  
+   -
AND
OR
For operators with equal precedence, the precedence is from left-to-right in expression.
integer a = 10, b = 35, c = 5
Comment about the output of the two statements?
print a * b + c / d
print c / d + a * b
Option 1 : Differ due to left-to-right precedence
Option 2 : Differ by 10
Option 3 : Differ by 20
Option 4 : Same

18. Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.)
*   /  
+   -
AND
OR
For operators with equal precedence, the precedence is from left-to-right in expression.
integer a = 40, b = 35, c = 20, d = 10

Comment about the output of the following two statements:

print a * b / c - d
print a * b / (c - d)
Option 1 : Differ by 80
Option 2 : Same
Option 3 : Differ by 50
Option 4 : Differ by 160

19. Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.)
*   /  
+   -
AND
OR
For operators with equal precedence, the precedence is from left-to-right in expression.
integer a = 60, b = 35, c = -30

What will be the output of the following two statements:
print ( a > 45 OR b > 50 AND c > 10 )
print ( ( a > 45 OR b > 50 ) AND c > 10 )
Option 1 : 0 and 1
Option 2 : 0 and 0
Option 3 : 1 and 1
Option 4 : 1 and 0

20. A pseudo-code is used. Assume that when two data-types are processed through an operator, the answer maintains the same data-type as the input data-types. Assume that all data-types have enough range to accommodate any number. If two different data-types are operated on, the result assumes the more expressive data-type.
// in pseudo code refers to comment
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
Option 1 : 984
Option 2 : 98.4
Option 3 : 98
Option 4 : Error

21. A pseudo-code is used. Assume that when two data-types are processed through an operator, the answer maintains the same data-type as the input data-types. Assume that all data-types have enough range to accommodate any number. If two different data-types are operated on, the result assumes the more expressive data-type.
// in pseudo code refers to comment
What will be the output of the following pseudo-code statements:
integer a = 984
//float is a data-type to store rational numbers.
float b= 10, c
c = a / b
print c
Option 1 : 984
Option 2 : Error
Option 3 : 98.4
Option 4 : 98

22. Smriti wants to make a program to print the sum of square of the first 5 whole numbers (0...4). She writes the following program:

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

Is her program correct? If not, which statement will you modify to correct it?
Option 1 : No error, the program is correct.
Option 2 : Statement 1
Option 3 : Statement 4
Option 4 : statement 6

23. Shashi wants to make a program to print the sum of the first 10 multiples of 5. She writes the following program, where statement 5 is missing:

integer i = 0
integer sum = 0   
while ( i <= 50 ) 
{
    sum = sum + i 
  -- MISSING STATEMENT 5 -- 
}   
print sum 

Which of the following will you use for statement 5?
Option 1 : i = 5
Option 2 : i = 5 * i
Option 3 : i = i + 1
Option 4 : i = i + 5

24. Shantanu wants to make a program to print the sum of the first 7 multiples of 6. He writes the following program:

integer i = 0 // statement 1
integer sum   // statement 2
while ( i <= 42 ) // statement 3
{
  sum = sum + i // statement 4
  i = i + 6;    
}   
print sum // statement 6

Does this program have an error? If yes, which one statement will you modify to correct the program?
Option 1 : Statement 1
Option 2 : Statement 2
Option 3 : Statement 3
Option 4 : Statement 4

25. Sharmili wants to make a program to print the sum of all perfect cubes, where the value of the cubes go from 0 to 100. She writes the following program:

integer i = 0, a    // statement 1
integer sum = 0; 
a = ( i * i * i )
while ( i < 100 ) // statement 2
  sum = sum + a // statement 3
  i = i + 1
  a = ( i * i * i )   // statement 4

}   
print sum 

Does this program have an error? If yes, which one statement will you modify to correct the program?
Option 1 : Statement 1
Option 2 : Statement 2
Option 3 : Statement 3
Option 4 : Statement 4
Option 5 : No error

26. Bhavya wants to make a program to print the sum of all perfect squares, where the value of the squares go from 0 to 50. She writes the following program:

integer i = 1, a // statement 1
integer sum = 0
while ( a < 50 ) // statement 2
  sum = sum + a // statement 3
  i = i + 1
  a = ( i * i );   // statement 4
}   
print sum 

Does this program have an error? If yes, which one statement will you modify to correct the program?
Option 1 : Statement 1
Option 2 : Statement 2
Option 3 : Statement 3
Option 4 : Statement 4
Option 5 : No error

27. Vijay wants to print the following pattern on the screen:
2
2 4
2 4 6
2 4 6 8

He writes the following program:

integer i = 1, j=2 // statement 1
while ( i <= 4 ) // statement 2
  j = 2;
  while ( j <= ? ) // Statement 3
  {
    print j
    print blank space
    j = j + 2
  }
  print end-of-line \takes the cursor to the next line
  i = i + 1
}

What is the value of ? in statement 3 ::
Option 1 : 8
Option 2 : i
Option 3 : 2*i
Option 4 : 4

28. Shravanti writes the following program:

integer i = 0, j 
while ( i < 2 ) 
  j = 0;
  while ( j <= 3*i ) 
  {
    print j
    print blank space
    j = j + 3
  }
  print end-of-line \takes the cursor to the next line
  i = i + 1
}

What will be the output of the program?
Option 1 : 0 0 3
Option 2 : 0 3 0 3 6
Option 3 : 0 0 3 6 0 3 6 9
Option 4 : 0 3 6 0 3 6 9 0 3 6 9 12

29. Vijay wants to print the following pattern on the screen:
1
1 2
1 2 3

He writes the following program:

integer i = 1 // statement 1
while ( i <= 3 )
{   
  int j // Statement 2
  while ( j <= i ) // Statement 3
  {
    print j
    print blank space
    j = j + 1 // Statement 4
  }
  print end-of-line \takes the cursor to the next line
  i = i + 1
}

Will this program function correctly? If not which one statement will you modify to make the program function correctly?
Option 1 : Statement 1
Option 2 : Statement 2
Option 3 : Statement 3
Option 4 : Statement 4
Option 5 : Program does not have error.

30. Charu writes the following program:

integer i = 1, j, a 
while ( i <= 4 ) 
  j = 1;
  a = 0;
  while ( a <= 5*i ) 
  {
    a = 2^j;
    print a
    print blank space
    j = j + 1
  }
  print end-of-line \takes the cursor to the next line
  i = i + 1
}

What will be the output of the program?
Option 1 : 2 2 4 2 4 8 2 4 8 16
Option 2 : 2 4 2 4 8 2 4 8 16 2 4 8 16 32
Option 3 : 2 4 2 4 8 2 4 8 2 4 8 16
Option 4 : 2 2 4 2 4 2 4 8 16

31. Himanshu wants to write a program to print the larger of the two inputted number. He writes the following code:

int number1, number 2
input number1, number 2
if ("??") // Statement 1
print number1
else
print number2
end if 
Fill in the ?? in statement 1.
Option 1 : number1>number2
Option 2 : number2>number1
Option 3 : number2 equals number1
Option 4 : number1 <= number2

32. Shalini wants to program to print the largest number out of three inputted numbers. She writes the following program:

int number1, number 2, number3, temp;
input number1, number2, number3;
if (number1>number2)
temp = number1
else 
  temp = number2
end if
if (??) // Statement 1
  temp = number3
end if
print temp

Fill in the ?? in Statement 1
Option 1 : number3 > number2
Option 2 : number3 > temp
Option 3 : number3 < temp
Option 4 : number3 > number1

33. Rohit writes the following program which inputs a number and prints "Double digit" if the number is composed of two digits and "Not a double digit" if it is not. 

int number;
if (number>10 AND number < 100)
  print "Double digit"
else 
  print "Not a double digit"
end if

Rohit tries the following inputs: 5 and 66. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn't work correctly. What did Ravi enter?   
Option 1 : 8
Option 2 : 100
Option 3 : 99
Option 4 : 10

34. Rohan writes the following program which inputs a number and prints "Triple digit" if the number is composed of three digits and "Not triple digit" if it is not. 

int number;
if (number>99)
  print "Triple digit"
else 
  print "Not triple digit"
end if

Rohan tries the following inputs: 25 and 566. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn't work correctly. What did Ravi enter?   
Option 1 : 99
Option 2 : 100
Option 3 : 0
Option 4 : 1000

35. Abhinav wants to find the largest number in a given list of 20 numbers. Which of the following is an efficient approach to do this?
Option 1 : Use bubble sort to sort the list in descending order and then print the first number of the series.
Option 2 : Use selection sort to sort the list in descending order and then print the first number of the series.
Option 3 : Implement one iteration of selection sort for descending order and print the first number in the series.
Option 4 : None of these
36. Lavanya wants to find the smallest number out of 26 inputted numbers. How many minimum comparisons he has to make?
Option 1 : 25
Option 2 : 13
Option 3 : 26
Option 4 : 52

37. A company offers commission for selling it products to its salesperson. The commission rate is Rs. 5 per product. However if the salesperson sells more than 200 items, he gets a commission of Rs. 10 on all items he sold after the first 200. Kanu writes a program to calculate the commission for the salesperson:

integer numberProducts, commission
input numberProducts

if ( numberProducts > 200 )
-- MISSING STATEMENT --
else
commission = numberProducts * 5
end if
print commission

Fill in the missing statement.
Option 1 : commission = (numberProducts - 200) * 10
Option 2 : commission = 200 * 5 + (numberProducts - 200) * 10
Option 3 : commission = numberProducts * 10
Option 4 : None of these

38. Vikram wants to write a program which checks whether the inputted number is divisible by any of the first 6 natural numbers (excluding 1). He writes the following efficient code for it.

int number, n = 2, isdivisible=0 
input number
while ( n <=6) // Statement 1
{
  if ( remainder (number, n) == 0)
    isdivisible = 1
  end
  n = n+1 // Statement 2
}
if (isdivisible equals 1)
  print "It is divisible"
else 
  print "It is not divisible"
end

Vikram takes the program to Hari. Hari tells Vikram that though the code is correct, it can be made more efficient. Hari modifies a single statement and makes the code more efficient. Which statement does he modify and how?
Option 1 : Statement 1 is changed to: while (n <=6 AND isdivisible=0)
Option 2 : Statement 1 is changed to: while (n <=6 OR isdivisible=0)
Option 3 : Statement 1 is changed to: while (isdivisible=0)
Option 4 : Statement 2 is changed to: n = n + 2

39. Rajiv wants to make a program which inputs two numbers: a and b (a>b) and   computes the number of terms between a and b (including a and b). What will be code statement to do this:
Option 1 : a - b
Option 2 : a - b + 1
Option 3 : a + b
Option 4 : a - b - 1

40. I have a problem to solve which takes as input a number n. The problem has a property that given the solution for (n-1), I can easily solve the problem for n. Which programming technique will I use to solve such a problem?
Option 1 : Iteration
Option 2 : Decision-making
Option 3 : Object Oriented Programming
Option 4 : Recursion

41. A pseudo-code is used with the following meaning.
"pointer" is a data-type which contains memory address (or pointers)
Statement "a = *b" puts the value at the memory address referenced by b into a.
Statement "a = &b" puts the memory address of b into a.
Statement "*b = a" puts the value a at the memory address referenced by b.
What is the output of the following code statements? The compiler saves the first integer at the memory location 4062. Integer is one byte long.

integer a
pointer b
a = 20
b = &a
print *b
Option 1 : 4062
Option 2 : 4063
Option 3 : 20
Option 4 : 10

42. A pseudo-code is used with the following meaning.
"pointer" is a data-type which contains memory address (or pointers)
Statement "a = *b" puts the value at the memory address referenced by b into a.
Statement "a = &b" puts the memory address of b into a.
Statement "*b = a" puts the value a at the memory address referenced by b.
What is the output of the following code statements? The compiler saves the first integer at the memory location 4165 and the rest at consecutive memory spaces in order of declaration. Integer is one byte long.

integer a, b
pointer c, d
a = 30
c = &a
b = *c
a = a + 10
print b
Option 1 : 30
Option 2 : 4165
Option 3 : 40
Option 4 : 4166

43. A pseudo-code is used with the following meaning.
"pointer" is a data-type which contains memory address (or pointers)
Statement "a = *b" puts the value at the memory address referenced by b into a.
Statement "a = &b" puts the memory address of b into a.
Statement "*b = a" puts the value a at the memory address referenced by b.
What is the output of the following code statements? The compiler saves the first integer at the memory location 4165 and the rest at consecutive memory spaces in order of declaration. Integer is one byte long.

integer a
pointer c, d
a = 30
c = &a
d = c
a = a + 10
print *c
Option 1 : 30
Option 2 : 4165
Option 3 : 40
Option 4 : 4166

44. What is space complexity of a program?
Option 1 : Amount of hard-disk space required to store the program
Option 2 : Amount of hard-disk space required to compile the program
Option 3 : Amount of memory required by the program to run
Option 4 : Amount of memory required for the program to compile

45. The memory space needed by an algorithm has a fixed part independent of the problem instance solved and a variable part which changes according to the problem instance solved. In general, which of these two is of prime concern to an algorithm designer?
Option 1 : Fixed part
Option 2 : Variable Part
Option 3 : Product of fixed part and variable part
Option 4 : None of these

46. While calculating time complexity of an algorithm, the designer concerns himself/herself primarily with the run time and not the compile time. Why?
Option 1 : Run time is always more than compile time.
Option 2 : Compile time is always more than run time.
Option 3 : Compile time is a function of run time.
Option 4 : A program needs to be compiled once but can be run several times.

47. Pankaj and Mythili were both asked to write the code to evaluate the following expression: 
a - b + c/(a-b) + (a-b)2 
Pankaj writes the following code statements (Code A):
print (a-b) + c/(a-b) + (a-b)*(a-b)
Mythili writes the following code statements (Code B):
d = (a-b)
print d + c/d + d*d
If the time taken to load a value in a variable, for addition, multiplication or division between two operands is same, which of the following is true?
Option 1 : Code A uses lesser memory and is slower than Code B
Option 2 : Code A uses lesser memory and is faster than Code B
Option 3 : Code A uses more memory and is faster than Code B
Option 4 : Code A uses more memory and is slower than Code B

48. Vrinda writes an efficient program to sum two square diagonal matrices (matrices with elements only on diagonal). The size of each matrix is nXn. What is the time complexity of Vrinda's algorithm?
Option 1 : θ(n^2)
Option 2 : θ(n)
Option 3 : θ(n*log(n))
Option 4 : None of these

49. Tarang writes an efficient program to add two upper triangular 10X10 matrices (elements on diagonal retained). How many total additions will his program make?
Option 1 : 100
Option 2 : 55
Option 3 : 25
Option 4 : 10

50. Ravi and Rupali are asked to write a program to sum the rows of a 2X2 matrices stored in the array  A.
Ravi writes the following code (Code A):
for n = 0 to 1
  sumRow1[n] = A[n][1] + A[n][2]
end

Rupali writes the following code (Code B):   
sumRow1[0] = A[0][1] + A[0][2]
sumRow1[1] = A[1][1] + A[1][2]
Comment upon these codes (Assume no loop-unrolling done by compiler):
Option 1 : Code A will execute faster than Code B.
Option 2 : Code B will execute faster than Code A
Option 3 : Code A is logically incorrect.
Option 4 : Code B is logically incorrect



Post a Comment

0 Comments