45
HUAWEI Aptitude (40 questions) 1. Kim can do a work in 3 days while David can do the same work in 2 days. Both of them finish the work together and get Rs.150. What is the share of Kim? A. Rs.30 B. Rs.60 C. Rs.70 D. Rs.75 Ans-B 2. Ronald and Elan are working on an assignment. Ronald takes 6 hours to type 32 pages on a computer, while Elan takes 5 hours to type 40 pages. How much time will they take, working together on two different computers to type an assignment of 110 pages? A. 7 hours 30 minutes B. 8 hours C. 8 hours 15 minut es

bda92830-7503-4406-b03a-1a6cab3a5760

Embed Size (px)

Citation preview

Page 1: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 1/45

HUAWEI Aptitude (40 questions)

1. Kim can do a work in 3 days while David can do the same work in 2 days. Both of them finish the work

together and get Rs.150. What is the share of Kim?

A. Rs.30

B. Rs.60

C. Rs.70

D. Rs.75

Ans-B

2. Ronald and Elan are working on an assignment. Ronald takes 6 hours to type 32 pages on a computer,

while Elan takes 5 hours to type 40 pages. How much time will they take, working together on two

different computers to type an assignment of 110 pages?

A. 7 hours 30 minutes

B. 8 hours

C. 8 hours 15 minutes

Page 2: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 2/45

 

D. 8 hours 25 minutes

Ans-C

3. A Car travels at an average of 50 miles per hour for 2x1/2 hours and then travels at a speed of 70

miles per hour for 1x1/2 hours. How far the car did travels in the entire 4 hours?

A. 120 miles

B. 150 miles

C. 200 miles

D. 230 miles

Ans-D

4. The distance between two cities A and B is 330 Km. A train starts from A at 8 a.m. and travel towards

B at 60 km/hr. Another train starts from B at 9 a.m and travels towards A at 75 Km/hr. At what time do

they meet?

A. 10 a.m

Page 3: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 3/45

 

B. 10.30 a.m

C. 11 a.m

D. 11.30 a.m

Ans-C

5. A man in a train notices that he can count 21 telephone posts in one minute. If they are known to be

50 metres apart, then at what speed is the train travelling?

A. 55 km/hr

B. 57 km/hr

C. 60 km/hr

D. 63 km/hr

Ans-C

Page 4: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 4/45

6. If m and n are whole numbers such that mn = 121, then the value of (m - 1)n+1 is

A. 1

B. 10

C. 121

D. 1000

Ans-D

7. If 3(x-y)= 27 and 3(x+y)=243, then x is equal to

A. 0

B. 2

C. 4

D. 6

Ans-C

Page 5: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 5/45

 

8. How many shares of market value Rs. 25 each can be purchased for Rs. 12750 brokerage being 2%?

A. 450

B. 500

C. 550

D. 600

Ans-B

9. The market value of a 10.5% stock, in which an income of Rs. 756 is derived by investing Rs. 9000,

brokerage being 1/4% is

A. Rs. 108.25

B. Rs. 112.20

C. Rs. 124.75

Page 6: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 6/45

D. Rs. 125.25

Ans-C

10. The cash realized on selling a 14% stock is Rs.106.25, brokerage being 1/4% is

A. Rs. 105.50

B. Rs. 106

C. Rs. 106.50

D. Rs. 113.75

Ans-B

11. What is the square of 0.16?

A. 0.4

B. 0.004

Page 7: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 7/45

 

C. 0.04

D. 4

Ans-A

12. A group of students decided to collect as many paise from each member of the group as is the

number of members. If the total collection amounts to Rs. 59.29, the number of members in the group

is

A. 17

B. 47

C. 97

D. 77

Ans-D

Page 8: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 8/45

13. N number of persons decided to raise Rs. 3 lakhs by equal contribution from each. Had they

contributed Rs. 50 each extra, the contribution would have been Rs. 3.25 lakhs. How many persons are

there?

A. 400

B. 500

C. 550

D. 600

Ans-B

14. On a sports day, if 30 children were made to stand in a column, then 16 columns could be formed. If 

24 children were to stand in a column, then how many columns could be formed?

A. 20

B. 22

C. 29

D. 452

Page 9: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 9/45

Ans-A

15. Along a yard 225 meters long, 26 trees are planted at equal distances, one tree being at each end of 

the yard. What is the distance between two consecutive trees?

A. 9 meters

B. 12 meters

C. 15 meters

D. 18 meters

Ans-A

16. A lent Rs. 5000 to B for 2 years and Rs. 3000 to C for 4 years on simple interest at the same rate of 

interest and received Rs. 2200 in all from both of them as interest. The rate of interest per annum is

A. 5%

B. 7%

Page 10: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 10/45

C. 8%

D. 10%

Ans-D

17. Reshma took a loan of Rs. 1200 with simple interest for as many years as the rate of interest. If she

paid Rs. 432 as interest at the end of the loan period, what was the rate of interest?

A. 3.6

B. 5.6

C. 6

D. 18

Ans-C

18. An iron cubes of side 10 cm is hammered into a rectangular sheet of thickness 0.5 cm. If the sides of 

the sheet are in the ratio 1 : 5 the sides are

Page 11: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 11/45

A. 10 cm, 50 cm

B. 20 cm, 100 cm

C. 40 cm, 200 cm

D. None of these

Ans-B

19. How many cubes of 10 cm edge can be put in a cubical box of 1 m edge?

A. 10

B. 100

C. 1000

D. 10000

Ans-C

Page 12: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 12/45

 

20. Three unbiased coins are tossed. What is the probability of getting at least 2 heads?

A. 1/2

B. 1/4

C. 1/3

D. 1/8

Ans-A

21. Two pipes A and B can separately fill a cistern in 60 minutes and 75 minutes respectively. There is a

third pipe in the bottom of the cistern to empty it. If all the three pipes are simultaneously opened, then

the cistern is full in 50 minutes. In how much time, the third pipe alone can empty the cistern?

A. 90 min

B. 100 min

C. 110 min

D. 120 min

Page 13: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 13/45

 

Ans-B

22. A fruit seller had some apples. He sells 40% apples and still has 420 apples. Originally, he had

A. 588 apples

B. 600 apples

C. 672 apples

D. 700 apples

Ans-D

23. How many liters of pure acid are there in 8 liters of a 20% solution?

A. 1.4

B. 1.5

Page 14: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 14/45

C. 1.6

D. 2.4

Ans-Cb

24. A train 220 m long is running with a speed of 59 kmph. In what time will it pass a man who is

running at 7 kmph in the direction opposite to that in which the train is going?

A. 10 sec.

B. 12 sec.

C. 14 sec.

D. 16 sec.

Ans-B

25. A 300 meter long train crosses a platform in 39 seconds while it crosses a signal pole in 18 seconds.

What is the length of the platform?

Page 15: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 15/45

A. 320 m

B. 350 m

C. 650 m

D. None of these

Ans-B

26. The difference between two numbers is 1356. When the larger number is divided by the smaller

one, the quotient is 6 and the remainder is 15. The smaller number is

A. 240

B. 370

C. 270

D. 360

Ans-C

Page 16: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 16/45

 

27. 252 can be expressed as a product of prime as

A. 2 x 2 x 3 x 3 x 7

B. 2 x 2 x 2 x 3 x 7

C. 3 x 3 x 3 x 3 x 7

D. 2 x 3 x 3 x 3 x 7

Ans-A

28. A box contains 2 white balls, 3 black balls and 4 red balls. In how many ways can 3 balls be drawn

from the box, if at least one black ball is to be included in the draw?

A. 48

B. 64

C. 69

D. 71

Page 17: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 17/45

Ans-B

29. My brother is 3 years elder to me. My father was 28 years of age when my sister was born while my

mother was 26 years of age when I was born. If my sister was 4 years of age when my brother was born,

then, what was the age of my father and mother respectively when my brother was born?

A. 32 yrs, 23 yrs

B. 32 yrs, 29 yrs

C. 35 yrs, 29 yrs

D. 35 yrs, 33 yrs

Ans-A

30. A man sells two flats at the rate of Rs.1.995 lakhs each. On one he gains 5% and on the other, he

loses 5%. His gain or loss percent in the whole transaction is

A. 0.25% loss

B. 0.25% gain

C. 2.5% loss

Page 18: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 18/45

D. 25% loss

Ans-A

31. Aman started a business investing Rs. 70,000. Rakhi joined him after six months with an amount of 

Rs.. 1,05,000 and Sagar joined them with Rs. 1.4 lakhs after another six months. The amount of profit

earned should be distributed in what ratio among Aman, Rakhi and Sagar respectively, 3 years after

Aman started the business?

A. 7 : 6 : 10

B. 12 : 15 : 16

C. 42 : 45 : 56

D. cannot be determined

Ans-B

32. Find out the wrong number in the series

1, 1, 2, 6, 24, 96, 720

Page 19: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 19/45

A. 720

B. 96

C. 24

D. 6

Ans-B

33. The digit in unit's place of the product (459 ×46×28×484) is 2, the digit in place of * is

A. 3

B. 5

C. 7

D. 9

Ans-C

Page 20: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 20/45

 

34. If logx 4 = 1/4, then x is equal to

A. 16

B. 64

C. 128

D. 256

Ans-D

35. From a point P on a level ground, the angle of elevation of the top tower is 30°. If the tower is 100 m

high, the distance of point P from the foot of the tower is:

A. 149 m

B. 156 m

C. 173 m

D. 200 m

Page 21: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 21/45

Ans-C

36. A watch which gains uniformly is 2 minutes low at noon on Monday and is 4 min. 48 sec fast at 2

p.m. on the following Monday. When was it correct?

A. 2 p.m. on Tuesday

B. 2 p.m. on Wednesday

C. 3 p.m. on Thursday

D. 1 p.m. on Friday

Ans-B

37. Find the day of the week on 25th december,1995?

A. Monday

B. Wednesday

C. Friday

Page 22: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 22/45

 

D. Sunday

Ans-A

38. A boat takes 19 hours for travelling downstream from point A to point B and coming back to a point

C midway between A and B. If the velocity of the stream is 4 kmph and the speed of the boat in still

water is 14 kmph, what is the distance between A and B ?

A. 160 km

B. 180 km

C. 200 km

D. 220 km

Ans-B

39. Students were asked to find the arithmetic mean of the numbers 3, 11, 7, 9, 15, 13, 8, 19, 17, 21, 14

and x. He found the mean to be 12. What should be the number in place of x?

A. 3

Page 23: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 23/45

 

B. 7

C. 17

D. 31

Ans-B

40. Vibin obtained 76, 65, 82, 67 and 85 marks (out in 100) in English, Mathematics, Physics, Chemistry

and Biology. What are his average marks?

A. 65

B. 69

C. 72

D. 75

Ans-D

Page 24: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 24/45

C Programming (20 questions)

1. What are the types of linkages?

A. Internal and External

B. External, Internal and None

C. External and None

D. Internal

Ans-B

2. What is the output of the program?

#include<stdio.h>

int main()

{

Page 25: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 25/45

 

extern int a;

printf("%d\n", a);

return 0;

}

int a=20;

A. 20

B. 0

C. Garbage Value

D. Error

Ans-A

3. Which of the following cannot be checked in a switch-case statement?

Page 26: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 26/45

A. Character

B. Integer

C. Float

D. enum

Ans-C

4. Which of the following are unary operators in C?

1. !

2. sizeof 

3. ~

4. &&

A. 1, 2

B. 1, 3

Page 27: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 27/45

 

C. 2, 4

D. 1, 2, 3

Ans-D

5. What will you do to treat the constant 3.14 as a float?

A. use float(3.14f)

B. use 3.14f 

C. use f(3.14)

D. use (f)(3.14)

Ans-B

6. The keyword used to transfer control from a function back to the calling function is

Page 28: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 28/45

A. switch

B. goto

C. go back

D. return

Ans-D

7. What will the SWAP macro in the following program be expanded to on preprocessing? will the code

compile?

#include<stdio.h>

#define SWAP(a, b, c)(c t; t=a, a=b, b=t)

int main()

{

int x=10, y=20;

SWAP(x, y, int);

Page 29: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 29/45

 

printf("%d %d\n", x, y);

return 0;

}

A. It compiles

B. Compiles with an warning

C. Not compile

D. Compiles and print nothing

Ans-C

8. In which header file is the NULL macro defined?

A. stdio.h

B. stddef.h

Page 30: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 30/45

C. stdio.h and stddef.h

D. stdlib.h

Ans-C

9. 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

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

A. int xstrlen(char *s)

Page 31: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 31/45

 

{

int length=0;

while(*s!='\0')

{ length++; s++; }

return (length);

}

B. int xstrlen(char s)

{

int length=0;

while(*s!='\0')

length++; s++;

return (length);

Page 32: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 32/45

}

C. int xstrlen(char *s)

{

int length=0;

while(*s!='\0')

length++;

return (length);

}

D. int xstrlen(char *s)

{

int length=0;

while(*s!='\0')

s++;

Page 33: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 33/45

 

return (length);

}

Ans-A

11. W\hat 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

12. What will be the output of the program?

Page 34: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 34/45

#include<stdio.h>

int main()

{

union var

{

int a, b;

};

union var v;

v.a=10;

v.b=20;

printf("%d\n", v.a);

return 0;

}

Page 35: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 35/45

 

Ans-20

13. What will be the output of the program ?

#include<stdio.h>

#include<string.h>

int main()

{

printf("%d\n", strlen("123456"));

return 0;

}

Ans-6

Page 36: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 36/45

 

14. If the file 'source.txt' contains a line "Be my friend" which of the following will be the output of 

below program?

#include<stdio.h>

int main()

{

FILE *fs, *ft;

char c[10];

fs = fopen("source.txt", "r");

c[0] = getc(fs);

fseek(fs, 0, SEEK_END);

fseek(fs, -3L, SEEK_CUR);

fgets(c, 5, fs);

puts(c);

Page 37: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 37/45

 

return 0;

}

Ans-end

15. What will be the output of the program (sample.c) given below if it is executed from the command

line (Turbo C in DOS)?

cmd> sample 1 2 3

/* sample.c */

#include<stdio.h>

int main(int argc, char *argv[])

{

int j;

Page 38: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 38/45

j = argv[1] + argv[2] + argv[3];

printf("%d", j);

return 0;

}

A. 6

B. sample 6

C. Error

D. Garbage value

Ans-C

16. Assuming a integer 2-bytes, What will be the output of the program?

#include<stdio.h>

int main()

{

Page 39: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 39/45

 

printf("%x\n", -1<<3);

return 0;

}

A. ffff 

B. fff8

C. 0

D. -1

Ans-B

17. What will be the output of the program?

#include<stdio.h>

int main()

Page 40: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 40/45

{

typedef float f;

static f *fptr;

float fval = 90;

fptr = &fval;

printf("%f\n", *fptr);

return 0;

}

Ans-90.000000

18. What will be the output of the program?

#include<stdio.h>

#include<stdlib.h>

Page 41: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 41/45

 

union employee

{

char name[15];

int age;

float salary;

};

const union employee e1;

int main()

{

strcpy(e1.name, "K");

printf("%s %d %f", e1.name, e1.age, e1.salary);

return 0;

Page 42: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 42/45

}

Ans-no error

19. Point out the error in the following program.

#include<stdio.h>

#include<stdlib.h>

int main()

{

char *ptr;

*ptr = (char)malloc(30);

strcpy(ptr, "RAM");

printf("%s", ptr);

free(ptr);

Page 43: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 43/45

 

return 0;

}

A. Error: in strcpy() statement.

B. Error: in *ptr = (char)malloc(30);

C. Error: in free(ptr);

D. No error

Ans-B

20. Point out the error in the following program.

#include<stdio.h>

#include<stdarg.h>

fun(...);

Page 44: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 44/45

int main()

{

fun(3, 7, -11.2, 0.66);

return 0;

}

fun(...)

{

va_list ptr;

int num;

va_start(ptr, n);

num = va_arg(ptr, int);

printf("%d", num);

}

Page 45: bda92830-7503-4406-b03a-1a6cab3a5760

7/28/2019 bda92830-7503-4406-b03a-1a6cab3a5760

http://slidepdf.com/reader/full/bda92830-7503-4406-b03a-1a6cab3a5760 45/45

 

A. Error: fun() needs return type

B. Error: ptr Lvalue required

C. Error: Invalid declaration of fun(...)

D. No error

Ans-C