Amazon Placement paper

Amazon Placement paper

 

1. Two tables emp(empid,name,deptid,sal) and dept(deptid,deptname) are there.write a query which displays empname,corresponding deptname also display those employee names who donot belong to any dept.

2. Write prefix and post fix notation for (a+b)*c-(d+e)^(f-g)

3. write program to swap 2 variables without using extra memory.

4. Find the output for the following C program fn f(x)
{
if(x<=0)
return;
else f(x-1)+x;
}

5. Find the output for the following C program main()
{
intx=2,y=6,z=6;
x=y=z;
printf(%d”,x)
}

6. Copy a a file form one host “amazon.chennai” to another host “anazon.bbsr”

7. You want to find out the value of the last element of an array. You write the following code. What will happen when you compile and run it.?
public class MyAr{
public static void main(String argv[]){
int[] i = new int[5];
System.out.println(i[5]);
}
}
1) An error at compile time
2) An error at run time
3) The value 0 will be output
4) The string “null” will be output.

8. . Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.

9. Write a program to remove duplicates from a sorted array.

10. In C, if you pass an array as an argument to a function, what actually gets passed?
A.  Value of elements in array
B.  First element of the array
C.  Base address of the array
D.  Address of the last element of array
Ans-C

 

 

11. What will be the output of the program ?


A.  2, 3, 4, 5 B.  1, 2, 3, 4
C.  0, 1, 2, 3 D.  3, 2, 1 0
Ans-B
12. What will be the output of the program if the array begins 1200 in memory?

A.  1200, 1202, 1204 B.  1200, 1200, 1200
C.  1200, 1204, 1208 D.  1200, 1202, 1200
Ans-B

13. Which of the following statements are correct about an array?
1:  The array int num[26]; can store 26 elements.
2:  The expression num[1] designates the very first element in the array.
3:  It is necessary to initialize the array at the time of declaration.
4:  The declaration num[SIZE] is allowed if SIZE is a macro.

A.  1   B.  1,4
C.  2,3   D.  2,4
Ans-B

14. Which of the following function is used to find the first occurrence of a given string in another string?
A.  strchr()   B.  strrchr()
C.  strstr()   D.  strnset()
Ans-C

15. Which of the following function is correct that finds the length of a string?

Ans-A

16. What will be the output of the program in 16-bit platform (Turbo C under DOS) ?

A.  8, 1, 4    B.  4, 2, 8
C.  4, 2, 4    D.  10, 3, 4
Ans-B

17. Which of the following statements are correct ?
1:  A string is a collection of characters terminated by ”.
2:  The format specifier %s is used to print a string.
3:  The length of the string can be obtained by strlen().
4:  The pointer CANNOT work on string.
A.  A, B   B.  A, B, C
C.  B, D   D.  C, D
Ans-B

18. What is the wrong in this program

19. Point out the error in the program?

A.  Error: invalid structure member
B.  Error: Floating point formats not linked
C.  No error
D.  None of above
Ans-B

20. What is the similarity between a structure, union and enumeration?
A.  All of them let you define new values
B.  All of them let you define new data types
C.  All of them let you define new pointers
D.  All of them let you define new structures
Ans-B

21. What will be the output of the program ?
#include<stdio.h>
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf(“%d, %d, %d, %d, %d, %d\n”, MON, TUE, WED, THU, FRI, SAT);
return 0;
}
A. -1, 0, 1, 2, 3, 4   B. -1, 2, 6, 3, 4, 5
C. -1, 0, 6, 2, 3, 4   D. -1, 0, 6, 7, 8, 9
Ans-D

22. What will be the output of the program ?

A. 103 Dotnet    B. 102 Java
C. 103 PHP    D. 104 DotNet
Ans-A

23. In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.h
A.  During editing   B. During linking
C.  During execution  D. During preprocessing
Ans-D

24. Point out the error in the program

A.  Error: unexpected end of file because there is no matching #endif
B.  The number is odd
C.  Garbage values
D.  None of above
Ans-A

25. What are the different types of real data type in C ?
A. float, double    B. short int, double, long int
C. float, double, long double  D. double, long int, float
Ans-C

26. Which statement will you add in the following program to work it correctly?

A.  #include<conio.h> B.  #include<math.h>
C.  #include<stdlib.h> D.  #include<dos.h>
Ans-B

27. What do the following declaration signify?
int *ptr[30];
A.  ptr is a pointer to an array of 30 integer pointers.
B.  ptr is a array of 30 pointers to integers.
C.  ptr is a array of 30 integer pointers.
D.  ptr is a array 30 pointers.
Ans-B

28. What is x in the following program?

A.  x is a pointer
B.  x is an array of three pointer
C.  x is an array of three function pointers
D.  Error in x declaration
Ans-C

29. In the following code snippet can we declare a new typedef named ptr even though struct employee has not been completely declared while using typedef?

A. Yes    B. No
Ans-A

30. What will be the output of the program?

A.  3, 4, 4, 3 B.  4, 3, 4, 3
C.  3, 3, 4, 4 D.  3, 4, 3, 4
Ans-B

APTITUDE
Predict the output or error(s) for the following:
1.

2.

3.

4

5.

2. What are the files which are automatically opened when a C file is executed?

3. what will be the position of the file marker?
a: fseek(ptr,0,SEEK_SET);
b: fseek(ptr,0,SEEK_CUR);

4. What is the problem with the following code segment?
while ((fgets(receiving array,50,file_ptr)) != EOF)

5. Predict the output or error(s)


6. Predict the output or error(s)


7. In the following pgm add a  stmt in the function  fun such that the address of
‘a’ gets stored in ‘j’.

Ans- *k = &a

8. What are the following notations of defining functions known as?

Ans
i.  ANSI C notation
ii. Kernighan & Ritche notation

9. Is the following statement a declaration/definition. Find what does it mean?
int (*x)[10];

Ans- Definition-x is a pointer to array of(size 10) integers.

10. . What is the output for the program given below

typedef enum errorType{warning, error, exception,}error;
main()
{
error g1;
g1=1;
printf(“%d”,g1);
}

Ans- Compiler error: Multiple declaration for error

11. What is the output for the program given below
typedef struct error{int warning, error, exception;}error;
main()
{
error g1;
g1.error =1;
printf(“%d”,g1.error);
}
Ans-1

12. What is the output for the program given below

Ans-bye

13. What is the output for the program given below

Ans-                              1       1       1       1
2       4       2       4
3       7       3       7
4       2       4       2
5       5       5       5
6       8       6       8
7       3       7       3
8       6       8       6
9       9       9       9

14. Declare an array of N pointers to functions returning pointers to functions             returning pointers to characters?
Ans- (char*(*)( )) (*ptr[N])( );

15. There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong?

16. Is there any difference between the two declarations,
1.      int foo(int *arr[]) and
2.      int foo(int *arr[2])
Ans-No

17. What is the subtle error in the following code segment?

18. What is wrong with the following code?

19. What is the hidden bug with the following  statement?
assert(val++ != 0);

20. Is the following code legal?
struct a
{
int x;
struct a b;
}
Ans-No

21. Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
aType *b;
};
}
Ans-no

22. Which version do you prefer of the following two,
1) printf(“%s”,str);      // or the more curt one
2) printf(str);
Ans-1

23. Find the output.
main()
{
char a[4]=”HELL”;
printf(“%s”,a);
}
Ans- HELL%@!~@!@???@~~!

24. Printf can be implemented by using  __________ list.
Ans-Verbal Length argument

25. The command which gives the  device of our system
Ans-Who

26. Which of following is correct:
a)For loops can be nested
b)For Loops may use the same Index
c)For loops cannot be overllapped
Ans:a,c

 

27. when the system starts which will execute?
Ans- Booting loader

 

28. ada is _____________ language
a)modular b)object based c)object oriented d)functional

 

29. The maximum level of the tree is
Ans-depth of the tree

 

30. which is used for storing pictures or graphics
a) mbr  b)mar  c)frame buffer  d)sdram

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top