2023 2024 Student Forum > Management Forum > Main Forum

 
  #2  
14th October 2014, 01:11 PM
Super Moderator
 
Join Date: Apr 2013
Re: Tips to prepare for L&T? Technical questions for the interview

As you are saying that you wants some tips to prepare for the L&T interview so, here I am providing you that:

LNT Aptitude Questions with Answers

1) What can be said of the following?

struct Node {
char *word;
int count;
struct Node left;
struct Node right;
}

a) Incorrect definition
b) Structures cannot refer to other structure
c) Structures can refer to themselves. Hence the statement is OK
d) Structures can refer to maximum of one other structure

Answer :c

2) What is the output of the following program?

main()
{
int a=10;
int b=6;
if(a=3)
b++;
printf("%d %d\n",a,b++);
}

a) 10, 6
b) 10, 7
c) 3, 6
d) 3, 7
e) none

Answer: d

3) What can be said of the following program?

main ()
{
enum Months {JAN =1,FEB,MAR,APR};
Months X = JAN;
if(X==1)
{
printf("Jan is the first month");
}
}

a) Does not print anything
b) Prints: Jan is the first month
c) Generates compilation error
d) Results in runtime error

Answer: b

4) What is the output of the following program?

int x= 0x65;
main()
{
char x;
printf("%d\n",x);
}

a) Compilation error
b) 'A'
c) 65
d) Unidentified

Answer: a

5) What is the output of the following program?

main()
{
int l=6;
switch(l)
{ default : l+=2;
case 4: l=4;
case 5: l++;
break;
}
printf("%d",l);
}

a) 8
b) 6
c) 5
d) 4
e) none

Answer: c

6) What is the output of the following program? (has been used to indicate a space)

main()
{
char s[]="Hello,.world";
printf(%15.10s",s);
}

a) Hello, World...
b)....Hello,. or
c) Hello,. or....
d) None of the above

Answer: d

7) What is the output of the following program?

main()
{
int x=20;
int y=10;
swap(x,y);
printf("%d %d",y,x+2);
}
swap(int x,int y)
{
int temp;
temp =x;
x=y;
y=temp;
}

a)10, 20
b) 20, 12
c) 22, 10
d)10, 22
e)none

Answer: d

8) What is the output of the following problem?

#define INC(X) X++
main()
{
int X=4;
printf("%d",INC(X++));
}

a) 4
b) 5
c) 6
d) compilation error
e) runtime error

Answer: d

9). What is the output of the following program?

main()
{
char *src = "Hello World";
char dst[100];
strcpy(src, dst);
printf("%s",dst);
}
strcpy(char *dst,char *src)
{
while(*src) *dst++ = *src++;
}

a) "Hello World"
b)"Hello"
c)"World"
d) NULL
e) unidentified

Answer: d

10) What is the size of the following union?

Assume that the size of int =2, size of float =4 and size of char =1.
Union Tag{
int a;
flaot b;
char c;
};

a) 2
b) 4
c) 1
d) 7

Answer: b

Predict the output or error(s) for the following Questions:

11) main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
a) 5 4 3 2 1
b) 5 3 4 1 2
c) 6 5 4 3 2
d) 4 2 3 6 5

Answer:a

Explanation:When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.

12) void main()
{
int const * p=5;
printf("%d",++(*p));
}

a) Integer
b) Constant
c) 5
d) Compiler error

Answer: d
Explanation: Compiler error: Cannot modify a constant value.
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".

13) main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
a) Error
b) I Love U
c) I hate U
d) None of these

Answer: c

Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .

14) main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}

a) 1 2
b) 1 3
c) 2 1
d) 3 1

Answer: a

Explanation:
The sizeof() operator gives the number of bytes taken by its operand. P is a character pointer, which needs one byte for storing its value (a character). Hence sizeof(*p) gives a value of 1. Since it needs two bytes to store the address of the character pointer sizeof(p) gives 2.

15) main()
{
printf("%x",-1<<4);
}

a) ff
b) fff
c) fff0
d) 4
e) None of these

Answer: c

Explanation :
-1 is internally represented as all 1's. When left shifted four times the least significant 4 bits are filled with 0's.The %x format specifier specifies that the integer value be printed as a hexadecimal value.

16) main()
{
int i=3;
switch(i)
{
defaultrintf("zero");
case 1: printf("one");
break;
case 2rintf("two");
break;
case 3: printf("three");
break;
}
}

a) 1
b) 2
c) 3
d) 4
Answer : c

Explanation :The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.

17) #define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}

a) sizeof(i)=1
b) sizeof(i)=2
c) sizeof(i)=3
d) sizeof(i)=4
Answer: 1

Explanation: Since the #define replaces the string int by the macro char

18) main()
{
int i=10;
i=!i>14;
Printf ("i=%d",i);
}

a) i=1
b) i=4
c) i=5
d) i=0

Answer: d

Explanation:In the expression !i>14 , NOT (!) operator has more precedence than ‘ >’ symbol. ! is a unary logical operator. !i (!10) is 0 (not of true is false). 0>14 is false (zero).



Here I am providing you the books to prepare your self for the interview


As you are saying that are going to give your interview so, Here I am providing you the interview question which can be asked to you in your interview like:

What is normalization?
What is the difference between Java and C++?
Tell me smartly about you?
What is the difference between a structure and a class?
Mention that your hobbies
What is primary key?
About your project
What is data structure?
About programming
What is the difference between C# and C++?
Data structures ,Operation system,C,C++,Oops
What is a copy constructor?
DBMS,SQL,Pointers
What is Object Oriented Programming features?
What is the difference between C & C++?
What is the difference between C# and C++?
What is operator loading and polymorphism?
What is a class?
What is the difference between primary key and unique key?
What are the advantages of using OOPS?
What is recursion?
Attached Files
File Type: pdf LNT Aptitude Questions with Answers.pdf (94.2 KB, 140 views)


Quick Reply
Your Username: Click here to log in

Message:
Options

Thread Tools Search this Thread



All times are GMT +5. The time now is 01:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
SEO by vBSEO 3.6.0 PL2

1 2 3 4