Escolar Documentos
Profissional Documentos
Cultura Documentos
LG Soft came here in our campus for recruitment drive on 9th Jan 2008. Here are some details abt the
process...
Brief Description of the process:-
Technical cum Aptitude test.
At least 2 tech interviews.
final HR interview.
No.of students appeared for the written test:-around 125.
The written test was having 45 ques based on 'C' and among them some ques were on Data
Structures + 15 ques based on general aptitude....
No sectional cut-off and negative marking were there.....Apti was very easy...but 'C' was a bit tricky..
At a first glance you would think that this would be the nswer...but if you read it carefully, you will be
getting differant answer... 'C' questions were based on function pointers, basics etc... You shuld have
a firm hand on 'C' and Data Structures...
After around 1/2 to 1 hours, result of the tests were announced.. around 45 were shortlisted. Then
after that, there were at least 2 rounds of technical interviews... Depending on one's performance in
the 1st round, he/she would be giving 2nd technical round.. I faced three rounds of technical
interviews.. The ques were based on C and Data Structures....
Once, you go into HR interview, after clearing all the initial interviews.. You will be selected. In the
evening, results were announced. 13 ppl got selected.. I was one of them. The joining is on 21st Jan.
If your C basics are very clear, then only you will be able to clear the tech interviews.. In order to get
selected you should have sound knowledge of 'C'
Some ques asked were:-
Rate ur self in C... function to get central node of the linked list.. reversing the linked list.. etc....
1. Statements :
R T, T @ M, M d D
Conclusions : I. D # T
II. M # T
2. Statements :
K d H, H % F, F # J
Conclusions : I. F K
II. J H
3. Statements :
W @ G, N G, N % V
Conclusions : I. W @ N
II. V G
4. Statements :
T Y, Y % M, M @ R
Conclusions : I. R # Y
II. T d M.
5. Among M, N, T, P and R each having different weight, who is the heaviest
?
I. T is heavier than P and M but lighter than N who is not the heaviest.
II. M is lighter than P.
6. How is D related to T ?
I. Ds brother is father of Ts sister.
II. Ts brother is son of Ds brother.
7. Raman is sitting to the immediate left of Harry but not next to Kamal.
Mahesh is sitting to the right of Kamal. If the four friends are sitting in a
circle who is sitting to the immediate right of Harry?
(1) Mahesh (2) Kamal
(3) Raman (4) Harry
(5) Cannot be determined
8. If 1 is subtracted from the last digit of each of the above numbers the sum
of the digits of how many of them are prime numbers?
(1) None (2) Two
(3) One (4) Three
(5) All five
9. If the digits in each of the above numbers are written in reverse order
which will be thesecond highest number?
(1) 251 (2) 359
(3) 487 (4) 526
(5) 972
23w
2. 10. Find the output of the following program
int *p,*q;
p=(int *)1000;
q=(int *)2000;
printf("%d",(q-p));
Ans: 500
11. A power station generates 500MW of power and exhausts 800MW as
waste heat into the environment. What is the efficiency of the power station?
24a) 61.5%
b) 38.5%
c) 62.5%
d) 23%
1.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. Hello b. Hello World c. HelloWorld d. None of the above
2.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. Ok it works b. Will this work? c. Ok it works Will this work? d. None of
the above
3.
main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
4.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
5.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
6.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
7.
oid main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
8.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
8.
main()
{
int x=5;
for(;x==0;x--) {
printf(x=%d\n, x--); }
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
9.
main()
{
int x=5;
for(;x!=0;x--) {
printf(x=%d\n, x--); }
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
10.
main()
{
int x=5;
{
printf(x=%d , x--); }
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. 3, -1, 1, 3, 5
11.
main()
{
unsigned int bit=256;
printf(%d, bit); }
{
unsigned int bit=512;
printf(%d, bit); }
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
12.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
13.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
14.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
15.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.); }
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
16.
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.); }
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
17.
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
11.
main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}
a. Runtime error.
b. Hello world c. Compile error
d. hello world
12.
main()
{
char * strA;
char * strB = I am OK; memcpy( strA, strB, 6);
}
a. Runtime error.
b. I am OK c. Compile error
d. I am O
13.
How will you print % character?
a. printf(\%) b. printf(\\%) c. printf(%%) d. printf(\%%)
14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(%d,perplexed); }
a. 0
b. 2
c. 4
d. none of the above
15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. Your Name b. compile error
c. Name d. Runtime error
16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. Your Name, Your Address b. Your Address, Your Address c. Your
Name Your Name d. None of the above
17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
Instructions:
1. Please ignore any case-sensitive errors and un-included libraries.
2. You may use the back of this question paper for any rough work.
Q1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Q2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Q3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
Q4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
Q5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
Q6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
Q7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4
Q8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
Q9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
Q10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Q11.
main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}
a. Runtime error.
b. Hello world
c. Compile error
d. hello world
Q12.
main()
{
char * strA;
char * strB = I am OK;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. I am OK
c. Compile error
d. I am O
Q13. How will you print % character?
a. printf(\%)
b. printf(\\%)
c. printf(%%)
d. printf(\%%)
Q14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(%d,perplexed);
}
a. 0
b. 2
c. 4
d. none of the above
Q15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. Your Name
b. compile error
c. Name
d. Runtime error
Extracts From the Original Paper.. !!
Instructions:
1. Please ignore any case-sensitive errors and un-included libraries.
2. You may use the back of this question paper for any rough work.
Q1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Q2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Q3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
Q4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
Q5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
Q6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
Q7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4
Q8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
Q9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
Q10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Q11.
main()
{
char *p = "hello world";
p[0] = H ;
printf("%s", p);
}
a. Runtime error.
b. ?Hello world?
c. Compile error
d. ?hello world?
Q12.
main()
{
char * strA;
char * strB = ?I am OK?;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. ?I am OK?
c. Compile error
d. ?I am O?
Q13. How will you print % character?
a. printf(?\%?)
b. printf(?\\%?)
c. printf(?%%?)
d. printf(?\%%?)
Q14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(?%d?,perplexed);
}
a. 0
b. 2
c. 4
d. none of the above
Q15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. ?Your Name?
b. compile error
c. ?Name?
d. Runtime error
Q16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. ?Your Name?, ?Your Address?
b. ?Your Address?, ?Your Address?
c. ?Your Name? ?Your Name?
d. None of the above
Q17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q18.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q19.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. ?Ok it works?
b. ?Will this work??
c. ?Ok it works Will this work??
d. None of the above
Q20.
main()
{
printf("%d, %d", sizeof( c ), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
Q21.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
Q22.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
Q23.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
Q24.
void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
Q25.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
Q26.
main()
{
int x=5;
for(;x==0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
Q27
main()
{
int x=5;
for(;x!=0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
Q28
main()
{
int x=5;
for(;x<= 0;x--)
{
printf(?x=%d ?, x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. ?3, -1, 1, 3, 5
Q29.
main()
{
{
unsigned int bit=256;
printf(?%d?, bit);
}
{
unsigned int bit=512;
printf(?%d?, bit);
}
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
Q30.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
Q31.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
a. 512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
Q32.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
Q33.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q34
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q35
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513
All are multiple choice (45 c questions, 15 aptitude) 1 hour duration
1. fseek() is used for:
2. calloc() returns -----
3. int a=10,b=3;
float c;
c=a/b;
printf("%f",c);
4. If we loose the head pointer in a linked list can we free the memory
5. main ()
{
struct asd{
struct asf{
int a;
int b;
};
int c;
}x;
}
a. compiler error
b. no error
c. rntime error
d. none
ans: a compiler error
6. struct {
char a;
long i;
char b;
char c;
}n;
how many bytes for the struuct in 32 bit compiler
(hint : it hav padding concept)
ans :12 bytes
7. int a=030;
printf("%d",printf("%o",a));
ans : 242
8. int a=1,b=2,c=3;
printf("%d%d",a,b,c);
what is the o/p?
ans : 1,2
9.syntax for passing command line arguments:
10. array definition
11. char a[]="ggfjg";
char b[];
b=a;
printf("%s%s",a,b);
what will b the o/p?
12. int a=5;
printf("%d%d%d",a,a<<2,a>>2);
o/p ?
ans:5201
13. main()
{
int i;
for(i=0;i<5;i++)
printf("%d",prime());
}
prime(){
static int i;
i=0;
return(i++);
}
14. unsigned in i=10;
while(i>=0)
i--;
how many times the loop will continue?
15. int a[]={0,1,2,3,4};
int *p;
p=a+4;
for(;p>=a;p--)
printf("%d",*p);
}
o/p?
ans:4 3 2 1 0
16.int i=1;
i=2*i++;
printf("%d",i);
17. wat is the declaration and initialization of a structure given below.
srtuct node{
18. A program based on strrchr()
19. given a tree...and asked to findout preorder
20.
rest of the questions are similar to the paper found in net for lg
like prgs based on memset, strrchr..etc.,
APTITUDE:
1. suppose two cars travel from same point in opposite directions and
travel 8m ,then each
car took left and travelled for 6m then what is the distance between the
two cars:
ans: 20
2. 64,16,4, 1/4, 1/16,---- fill in the next term
3. 4 years ago father was 9 times older than his son. after 2 years
father was 40.what is
the present age of his son
4. a monkey jumps 3ft up and fell down 2ft.Then in how many jumps does it
vud reach 20 ft
5. A person eats 100 bananas in 5 days.Each day he eats 6 more bananas
then how many
bananas did he ate on the first day
6. 'A' is taller than 'B'
'C' is shorter than 'A'
who is the shorter among B and C
7. P is a point in a line segment AB.then
given 4 conditons like AB>PA
8.
ABOUT INTERVIEW:
48 attended the test and 26 were shortlisted.... 2 tech interview and 1 hr
interview...
those who pass d 1st one vud go to next round
tech 1 lasted for around 30-50 min
tech 2 was for around 15 min
and hr is for 15 min
some of the questins which we remember are presented below:
1.about structure padding...write code and explain its advantage
(imp....that is important)
2.tell me about urself
3.about malloc,calloc ,realloc functions..there difference
vat do dey return (imp)
4.process and thread differnce...tell me example...which one is
advantageous
5.reverse linked list using recursion
6.recursion...its need and usage...we hav loop then y do v go for recursion
7.do u know any string functions...
yes sir...strcmp,strcpy...
then write ur own code for string compare without using predefined
functions..
to 1 guy dey asked strstr code of our own
8.what r the real time os u hav worked on.do u know anything abt rtlinux
9.about dangling pointer
10.about project (important)
like...
a) ur role
b) microcontroller used
c)about the coding...cross compilers used....microcontroller
features
d)what is cross compiler
e)what is RS232...what does 232 signify in it
11. about function pointers and its application
12.double linked list prg
13. complexities of diff sorting and searching algo
14.using realloc increase mem
15.i need to allocate 100 bytes...but this 100 bytes are not free
continuosly in memory..
then can u allocate it using malloc....
if u cant allocate vat does it return
16. there is a linked list a->b->c->d->e
i dont have the starting address node... i hav only the address of c.
i hav another new node n.write a function say callback() which gives
the output as
a->b->n->c->d->e
17. how to pass command line arguments
18.*p++ ,++*p what is d difference between them
19. -17 is given.find out the no. of 1's in -17 binary representation
20.what does malloc return if it fails
21.write about ARM architecture
22.why do v need cross compilers
23.tell me some thing about thumb instruction
24.what is semaphore...mutual exclusion
25.difference between mutex and semaphore
26.after calloc if we reallocte mem..but v dont hav sufficient mem...what
does it do...if it
allocates mem in some new page
who is going to take care of copying the contents of previous calloc to
this reallocated
mem
27.main()
{
char *p;
p=calloc(1,10);
strcpy(p,hello);
test(p);
printf("%s",p);
free(p);
}
test(char *q)
{
free(q);
}
what is d o/p and why?
28. insert a node in linked list
29.difference between #define and typedef
30.about memory leakage
31.how to shrink d size using realloc
32.difference between function prototype nad declaration
33.swapping two variables using call by reference without using 3rd
varaible
34.can u write OS programs in application layer and run it
35.latest technologies in wireless
36. when a prg is written how does it get stored in memory...like where
does static variable
get stored
37.
HR ROUND:
1.tell me about urself(asked in every round)
2.tell me about ur educational background
3.what is the effect of IT on common man
i said it doesn't had a gr8 impact on every common man....he said that
der r few
affects...tell me 3 examples abt it...but dont try to prove me wrong
4.ur strategy to work
5.what did u gain from ur college life
6.what still remains with u after ur college life
7.what is embedded system
8.give me 3 examples abt embedded sys
9.ur expected salary
10.do u hav any query with u to ask
11. why do u want to b an engineer
12.why do u hav a year gap in between
13.brief me about IT industry
14.what r ur achievements
15.why should i hire u
16.why do u hav variations in ur b.tech % ..what went wrong
17.tell the name of CEO of any 5 companies and CEO of lg
18.
for some of them they hav asked questions which are irrelevant like:
a) how many bones does a human have
b)what is C6H6
c)about periodic table...inert gases...etc.,
Hey ppl...LG Soft came here in our campus for recruitment drive on 9th Jan
2008..Here are some details abt the process...
Brief Description of the process:-
Tecncal cum Aptitude test.
At least 2 tech interviews.
fnal HR interview.
No.of students appeared for the wriitten test:-around 125.
The written test was havin 45 ques based on 'C' and among them some ques were
on Data Structures + 15 ques based on general aptitude....
No sectional cut-off and negative marking were there.....Apti was very easy...but
'C' was a bit tricky....At a first glance...you would think that this would be the
nswer...but if you read it carefully, you will be getting differant answer...'C'
questions were based on function pointers,
basics etc....You shuld have a firm hand on 'C' and Data Structures.....
After around 1/2 to 1 hours, result of the tests were announced....around 45 were
shortlisted.....Then after that, there were at lest 2 rounds of technical
interviews....Depending on one's performance in the 1st round, he/she would be
giving 2nd technical round....I faced three rounds of technical interviews...The ques
were based on C and Data Structures....
Once, you go into HR interview, after clearing all the initial interviews...You will be
selected... In the evening, results were announced....13 ppl got selected...I was
one of them....The joining is on 21st Jan... If your C basics are very clear,then only
you will be able to clear the tech interviews...In order to get selected...you should
have sound knowledge of 'C'
Some ques asked were:-
Q1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Q2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Q3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
Q4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
Q5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
Q6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
Q7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4
Q8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
Q9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
Q10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Q11.
main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}
a. Runtime error.
b. Hello world
c. Compile error
d. hello world
Q12.
main()
{
char * strA;
char * strB = I am OK;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. I am OK
c. Compile error
d. I am O
Q13. How will you print % character?
a. printf(\%)
b. printf(\\%)
c. printf(%%)
d. printf(\%%)
Q14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(%d,perplexed);
}
a. 0
b. 2
c. 4
d. none of the above
Q15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. Your Name
b. compile error
c. Name
d. Runtime error
Q16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. Your Name, Your Address
b. Your Address, Your Address
c. Your Name Your Name
d. None of the above
Q17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. Hello
b. Hello World
c. HelloWorld
d. None of the above
Q18.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. Hello
b. Hello World
c. HelloWorld
d. None of the above
Q19.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. Ok it works
b. Will this work?
c. Ok it works Will this work?
d. None of the above
Q20.
main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
Q21.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
Q22.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
Q23.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
Q24.
void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
Q25.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
Q26.
main()
{
int x=5;
for(;x==0;x--) {
printf(x=%d\n, x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
Q27
main()
{
int x=5;
for(;x!=0;x--) {
printf(x=%d\n, x--);
}
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
Q28
main()
{
int x=5;
for(;x<= 0;x--)
{
printf(x=%d , x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. 3, -1, 1, 3, 5
Q29.
main()
{
{
unsigned int bit=256;
printf(%d, bit);
}
{
unsigned int bit=512;
printf(%d, bit);
}
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
Q30.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
Q31.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
a. 512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
Q32.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
Q33.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q34
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q35
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513
Q1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Q2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Q3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
Q4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
Q5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
Q6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
Q7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4
Q8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
Q9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
Q10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Q11.
main()
{
char *p = "hello world";
p[0] = H ;
printf("%s", p);
}
a. Runtime error.
b. ?Hello world?
c. Compile error
d. ?hello world?
Q12.
main()
{
char * strA;
char * strB = ?I am OK?;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. ?I am OK?
c. Compile error
d. ?I am O?
Q13. How will you print % character?
a. printf(?\%?)
b. printf(?\\%?)
c. printf(?%%?)
d. printf(?\%%?)
Q14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(?%d?,perplexed);
}
a. 0
b. 2
c. 4
d. none of the above
Q15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. ?Your Name?
b. compile error
c. ?Name?
d. Runtime error
Q16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. ?Your Name?, ?Your Address?
b. ?Your Address?, ?Your Address?
c. ?Your Name? ?Your Name?
d. None of the above
Q17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q18.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q19.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. ?Ok it works?
b. ?Will this work??
c. ?Ok it works Will this work??
d. None of the above
Q20.
main()
{
printf("%d, %d", sizeof( c ), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
Q21.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
Q22.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
Q23.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
Q24.
void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
Q25.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
Q26.
main()
{
int x=5;
for(;x==0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
Q27
main()
{
int x=5;
for(;x!=0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
Q28
main()
{
int x=5;
for(;x<= 0;x--)
{
printf(?x=%d ?, x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. ?3, -1, 1, 3, 5
Q29.
main()
{
{
unsigned int bit=256;
printf(?%d?, bit);
}
{
unsigned int bit=512;
printf(?%d?, bit);
}
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
Q30.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
Q31.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
a. 512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
Q32.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
Q33.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q34
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q35
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513
Q1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Q2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Q3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
Q4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
Q5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
Q6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
Q7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4
Q8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
Q9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
Q10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Q11.
main()
{
char *p = "hello world";
p[0] = H ;
printf("%s", p);
}
a. Runtime error.
b. ?Hello world?
c. Compile error
d. ?hello world?
Q12.
main()
{
char * strA;
char * strB = ?I am OK?;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. ?I am OK?
c. Compile error
d. ?I am O?
Q13. How will you print % character?
a. printf(?\%?)
b. printf(?\\%?)
c. printf(?%%?)
d. printf(?\%%?)
Q14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(?%d?,perplexed);
}
a. 0
b. 2
c. 4
d. none of the above
Q15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. ?Your Name?
b. compile error
c. ?Name?
d. Runtime error
Q16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. ?Your Name?, ?Your Address?
b. ?Your Address?, ?Your Address?
c. ?Your Name? ?Your Name?
d. None of the above
Q17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q18.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q19.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. ?Ok it works?
b. ?Will this work??
c. ?Ok it works Will this work??
d. None of the above
Q20.
main()
{
printf("%d, %d", sizeof( c ), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
Q21.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
Q22.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
Q23.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
Q24.
void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
Q25.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
Q26.
main()
{
int x=5;
for(;x==0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
Q27
main()
{
int x=5;
for(;x!=0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
Q28
main()
{
int x=5;
for(;x<= 0;x--)
{
printf(?x=%d ?, x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. ?3, -1, 1, 3, 5
Q29.
main()
{
{
unsigned int bit=256;
printf(?%d?, bit);
}
{
unsigned int bit=512;
printf(?%d?, bit);
}
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
Q30.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
Q31.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
a. 512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
Q32.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
Q33.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q34
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q35
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513
Q1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Q2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Q3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
Q4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
Q5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
Q6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
Q7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4
Q8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
Q9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
Q10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Q11.
main()
{
char *p = "hello world";
p[0] = H ;
printf("%s", p);
}
a. Runtime error.
b. ?Hello world?
c. Compile error
d. ?hello world?
Q12.
main()
{
char * strA;
char * strB = ?I am OK?;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. ?I am OK?
c. Compile error
d. ?I am O?
Q13. How will you print % character?
a. printf(?\%?)
b. printf(?\\%?)
c. printf(?%%?)
d. printf(?\%%?)
Q14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(?%d?,perplexed);
}
a. 0
b. 2
c. 4
d. none of the above
Q15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. ?Your Name?
b. compile error
c. ?Name?
d. Runtime error
Q16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. ?Your Name?, ?Your Address?
b. ?Your Address?, ?Your Address?
c. ?Your Name? ?Your Name?
d. None of the above
Q17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q18.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above
Q19.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. ?Ok it works?
b. ?Will this work??
c. ?Ok it works Will this work??
d. None of the above
Q20.
main()
{
printf("%d, %d", sizeof( c ), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
Q21.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
Q22.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
Q23.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
Q24.
void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
Q25.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
Q26.
main()
{
int x=5;
for(;x==0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
Q27
main()
{
int x=5;
for(;x!=0;x--) {
printf(?x=%d\n?, x--);
}
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
Q28
main()
{
int x=5;
for(;x<= 0;x--)
{
printf(?x=%d ?, x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. ?3, -1, 1, 3, 5
Q29.
main()
{
{
unsigned int bit=256;
printf(?%d?, bit);
}
{
unsigned int bit=512;
printf(?%d?, bit);
}
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
Q30.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
Q31.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
a. 512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
Q32.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
Q33.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q34
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(?OK I am gone.?);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q35
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513
1. Are you ready to move to any place if you get selected?
2. Will you sign a bond with us?
3. What is multiplexed in microprocessor?
4. Do you want to ask me anything regarding your job profile?
5. What do you know about the company?
1. Are you ready to move to any place if you get selected?
2. Will you sign a bond with us?
3. What is multiplexed in microprocessor?
4. Do you want to ask me anything regarding your job profile?
5. What do you know about the company?
1. Find the least number of students in an exam so that the percentage of successful students should be
76.8%:
(a) 500
(b) 250
(c) 125
(d) 1000
2. Aman sends a certain quantity of rice for 30 girls in a hostel. One day some girls were absent. Therefore,
the quantity of rice was spent in the ratio of 6: 5. How many girls were present on that day?
(a) 24
(b) 20
(c) 15
(d) 25
3. What is the ratio of buy price and sell price if there is deep loss of 12 1/(2 )%
(a) 7 : 8
(b) 8: 7
(c) 2: 25
(d) 25: 2
4. Find H.C.F. of 3/5, .36, .24
(a) .04
(b) 2
(c) .4
(d) None of the above
5. Simplify:
(1.3*1.3*1.3-1)/(1.3*1.3+1.3+1)
(a) .3
(b) 31/3
(c) ..3
(d) 1
6. Find the perfect mirror image of figure (X) from the following four alternatives.
(X) (1) (2) (3) (4)
A. 1
B. 2
C. 3
D. 4
7. Find the perfect mirror image of figure (X) from the following four alternatives.
(X) (1) (2) (3) (4)
A. 1
B. 2
C. 3
D.4
8. Statements:
All fruits are vegetables. All pencils are vegetables. All vegetables are rats.
Conclusions:
1. All fruits are rats.
2. All pencils are rats.
3. Some rats are vegetables.
A. None follows
B. Only I and II follow
C. Only II and III follow
D. Only I and III follow
E. All follow
9.
10. The jacket is impervious to water.
A) Dirty
B) Pure
C) Impenetrable
D) Favorable
11) The officer received _____ official letter from _____ Ministry of IT in _____ Central Government.
A) A, the, an
C) An, the, the
B) A, an, the
D) An, an, the
C++ Interview Questions - LG Soft
Adarsh 01-4-2012 06:31 AM
1. What will be the value of i & j?
for(i=0,j=0;i<5,j<25;i++,j++)
(a) i=4,j= 24 (b) i=24,j= 24 (c) i=25,j= 25 (d) i=5,j=25
2. What is the output of the following program?
main()
{
int i,j;
i=10;
j=sizeof(++i);
cout<<i;
}
(a) 11 (b) 10 (c) 4 (d) Compiler Error
3. What is the output of the following program?
main()
{
int i=7;
cout<<i++*i++;
}
(a) 49 (b) 56 (c) 72 (d) Compiler error
4. What is the output of the following program.
main()
{
char *p,*f();
p=f();
cout<< f() returns:<<p;
}
char *f()
{
char result[80];
strcpy(result,"anything will do");
return (result);
}
(a) f() returns: anything will do
(b) f() returns: result
(c) Compiler error
(d) None
5. How to initialize a pointer to a function?
6. Can a C++ program be linked with a C program?
7. How a function can return a structure?
8. Write a program to reverse a link list?
9. What are the advantages of exceptions in C++?
</p;
</i++*i++;
</i;
1.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. Hello b. Hello World c. HelloWorld d. None of the above
2.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. Ok it works b. Will this work? c. Ok it works Will this work? d. None of the above
3.
main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
4.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
5.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
6.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
7.
oid main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
8.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
8.
main()
{
int x=5;
for(;x==0;x--) {
printf(x=%d\n, x--); }
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
9.
main()
{
int x=5;
for(;x!=0;x--) {
printf(x=%d\n, x--); }
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
10.
main()
{
int x=5;
{
printf(x=%d , x--); }
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. 3, -1, 1, 3, 5
11.
main()
{
unsigned int bit=256;
printf(%d, bit); }
{
unsigned int bit=512;
printf(%d, bit); }
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
12.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
13.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
14.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
15.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.); }
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
16.
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.); }
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
17.
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
Here are the details of 2011 LG Soft India Placment Paper -I job in LG Electronics
Here you will find 2011 LG Soft India Placement Papers - I with Answers and Solutions
2011 LG Soft India Placement Paper - I:-
1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
11.
main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}
a. Runtime error.
b. Hello world c. Compile error
d. hello world
12.
main()
{
char * strA;
char * strB = I am OK; memcpy( strA, strB, 6);
}
a. Runtime error.
b. I am OK c. Compile error
d. I am O
13.
How will you print % character?
a. printf(\%) b. printf(\\%) c. printf(%%) d. printf(\%%)
14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(%d,perplexed); }
a. 0
b. 2
c. 4
d. none of the above
15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. Your Name b. compile error
c. Name d. Runtime error
16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the
above
17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
LG SOFT PAPER
Instructions:
1. Please ignore any case-sensitive errors and un-included libraries.
2. You may use the back of this question paper for any rough work.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
main()
{
int i = 0xff;
printf("%d", ipName);
}
a. Your Name b. compile error
c. Name d. Runtime error
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. Hello b. Hello World c. HelloWorld d. None of the above
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. Hello b. Hello World c. HelloWorld d. None of the above
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. Ok it works b. Will this work? c. Ok it works Will this work? d. None of the above
main()
{
printf("%d, %d", sizeof(,c,), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
oid main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
main()
{
int x=5;
for(;x==0;x--) {
printf(x=%d\n, x--); }
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
main()
{
int x=5;
for(;x!=0;x--) {
printf(x=%d\n, x--); }
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
main()
{
int x=5;
{
printf(x=%d , x--); }
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. 3, -1, 1, 3, 5
main()
{
unsigned int bit=256;
printf(%d, bit); }
{
unsigned int bit=512;
printf(%d, bit); }
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
main()
{
int i;
for(i=0;i (i - (i -1))));
}
}
512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.); }
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.); }
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513
Q29.
main()
{
{
unsigned int bit=256;
printf(%d, bit);
}
{
unsigned int bit=512;
printf(%d, bit);
}
}
a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error
Q30.
main()
{
int i;
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16
Q31.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit = (bit >> (i - (i -1))));
}
}
a. 512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4
Q32.
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256
Q33.
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q34
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf(OK I am gone.);
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Q35
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513
Q1.
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Q2.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Q3.
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("%d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
Q4.
main()
{
int i = 0xff;
printf("%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024
Q5.
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
Q6.
union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
Q7.
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("%d", sizeof(u));
printf("%d", sizeof(u.a));
printf("%d", sizeof(u.a[0].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4
Q8.
main()
{
int (*functable[2])(char *format, ...) ={printf, scanf};
int i = 100;
(*functable[0])("%d", i);
(*functable[1])("%d", i);
(*functable[1])("%d", i);
(*functable[0])("%d", &i);
}
a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number
Q9.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; /* Address of i is assigned to pointer p */
printf("%f", i/(*p)); /* i is divided by pointer p */
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000
Q10.
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Q11.
main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}
a. Runtime error.
b. Hello world
c. Compile error
d. hello world
Q12.
main()
{
char * strA;
char * strB = I am OK;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. I am OK
c. Compile error
d. I am O
Q13. How will you print % character?
a. printf(\%)
b. printf(\\%)
c. printf(%%)
d. printf(\%%)
Q14.
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf(%d,perplexed);
}
a. 0
b. 2
c. 4
d. none of the above
Q15.
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. Your Name
b. compile error
c. Name
d. Runtime error
Q16.
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. Your Name, Your Address
b. Your Address, Your Address
c. Your Name Your Name
d. None of the above
Q17.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. Hello
b. Hello World
c. HelloWorld
d. None of the above
Q18.
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. Hello
b. Hello World
c. HelloWorld
d. None of the above
Q19.
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. Ok it works
b. Will this work?
c. Ok it works Will this work?
d. None of the above
Q20.
main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4
Q21.
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
Q22.
main()
{
int c = 5;
printf("%d", main|c);
}
a. 1
b. 5
c. 0
d. none of the above
Q23.
main()
{
char c;
int i = 456;
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above
Q24.
void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
Q25.
main()
{
int i =10, j = 20;
printf("%d, %d\n", j-- , --i);
printf("%d, %d\n", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
Q26.
main()
{
int x=5;
for(;x==0;x--) {
printf(x=%d\n, x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above
Q27
main()
{
int x=5;
for(;x!=0;x--) {
printf(x=%d\n, x--);
}
}
a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above
Q28
main()
{
int x=5;
for(;x<= 0;x--)
{
printf(x=%d , x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. 3, -1, 1, 3, 5
Print Right View of a Binary Tree
Given a Binary Tree, print Right view of it. Right view of a Binary Tree is
set of nodes visible when tree is visited from Right side.
Right view of following tree is 1 3 7 8
1
/ \
2 3
/ \ / \
4 5 6 7
\
8
We strongly recommend to minimize the browser and try this
yourself first.
The Right view contains all nodes that are first nodes in their levels. A
simple solution is to dolevel order traversal and print the last node in
every level.
The problem can also be solved using simple recursive traversal. We
can keep track of level of a node by passing a parameter to all recursive
calls. The idea is to keep track of maximum level also. And traverse the
tree in a manner that right subtree is visited before left subtree.
Whenever we see a node whose level is more than maximum level so
far, we print the node because this is the first node in its level (Note that
we traverse the right subtree before left subtree). Following is C
implementation of this approach.
// C program to print right view of Binary Tree
#include<stdio.h>
#include<stdlib.h>
struct Node
{
int data;
struct Node *left, *right;
};
// A utility function to create a new Binary Tree Node
struct Node *newNode(int item)
{
struct Node *temp = (struct Node *)malloc(sizeof(struct Node));
temp->data = item;
temp->left = temp->right = NULL;
return temp;
}
// Recursive function to print right view of a binary tree.
void rightViewUtil(struct Node *root, int level, int *max_level)
{
// Base Case
if (root==NULL) return;
// If this is the first Node of its level
if (*max_level < level)
{
printf("%d\t", root->data);
*max_level = level;
}
// Recur for right subtree first, then left subtree
rightViewUtil(root->right, level+1, max_level);
rightViewUtil(root->left, level+1, max_level);
}
// A wrapper over rightViewUtil()
void rightView(struct Node *root)
{
int max_level = 0;
rightViewUtil(root, 1, &max_level);
}
// Driver Program to test above functions
int main()
{
struct Node *root = newNode(1);
root->left = newNode(2);
root->right = newNode(3);
root->left->left = newNode(4);
root->left->right = newNode(5);
root->right->left = newNode(6);
root->right->right = newNode(7);
root->right->left->right = newNode(8);
rightView(root);
return 0;
}
Output:
1 3 7 8
Time Complexity: The function does a simple traversal of the tree, so the
complexity is O(n).