Mar 22, 2011

37. Find the output


main()
{
    float arr[] = {12.4, 2.3, 4.5, 6.7};
    printf("%d\n", sizeof(arr)/sizeof(arr[0]));
}
Answer: 4
Explanation:
The sizeof function return the given variable. Example: float a=10; sizeof(a) is 4 bytes
Step 1float arr[] = {12.4, 2.3, 4.5, 6.7}; The variable arr is declared as an floating point array and it is initialized with the values.
Step 2printf("%d\n", sizeof(arr)/sizeof(arr[0]));
The variable arr has 4 elements. The size of the float variable is 4 bytes.
Hence 4 elements x 4 bytes = 16 bytes
sizeof(arr[0]) is 4 bytes
Hence 16/4 is 4 bytes
Hence the output of the program is '4'.

Mar 16, 2011

36. How much does a watch lose per day, if its hands coincide ever 64 minutes?


Answer: 
328min.
11


Explanation:

55 min. spaces are covered in 60 min.
60 min. spaces are covered in60x 60min.= 655min.
5511

Loss in 64 min. =655- 64=16min.
1111

Loss in 24 hrs =16x1x 24 x 60min.=328min.
116411

Mar 13, 2011

35. Find the ouput.

#include<stdio.h>
int i;
int fun();

int main()
{
    while(i)
    {
        fun();
        main();
    }
    printf("Hello\n");
    return 0;
}
int fun()
{
    printf("Hi");
}
Answer: Hello
Explanation:
Step 1: int i; The variable i is declared as an integer type.
Step 1: int fun(); This prototype tells the compiler that the function fun() does not accept any arguments and it returns an integer value.
Step 1: while(i) The value of i is not initialized so this while condition is failed. So, it does not execute the while block.
Step 1: printf("Hello\n"); It prints "Hello".
Hence the output of the program is "Hello".

Mar 11, 2011

34. An error 2% in excess is made while measuring the side of a square. The percentage of error in the calculated area of the square is ?


Answer: 4.04%

Explanation:
100 cm is read as 102 cm.
 A1 = (100 x 100) cm2 and A2 (102 x 102) cm2.
(A2 - A1) = [(102)2 - (100)2]
= (102 + 100) x (102 - 100)
= 404 cm2.
 Percentage error =404x 100%= 4.04%
100 x 100

Mar 9, 2011

33. A and B can do a work in 8 days, B and C can do the same work in 12 days. A, B and C together can finish it in 6 days. A and C together will do it in :

Answer: 8 days

Explanation:


(A + B + C)'s 1 day's work = 1 ;
6

(A + B)'s 1 day's work = 1 ;
8

(B + C)'s 1 day's work = 1 .
12

Therefore (A + C)'s 1 day's work
= ( 2 x 1 ) - ( 1 + 1 )
6 8 12

= ( 1 - 5 (
3 24

= 3
24

= 1 .
8
So, A and C together will do the work in 8 days.

Mar 8, 2011

32. Student A has secured 9 marks more than student B and A's marks was 56% of the sum of A&B's marks. The marks obtained by A and B are??

Answer: 
42,33

Explanation:
Let their marks be (x + 9) and x.
Then, x + 9 =56(x + 9 + x)
100

 25(x + 9) = 14(2x + 9)
 3x = 99
 x = 33
So, their marks are 42 and 33.

Mar 7, 2011

31. Find the missing number in 16, 33, 65, 131, 261, _____


Answer: 523
Explanation:
Each number is twice the preceding one with 1 added or subtracted alternatively.
So, the next number is (2 x 261 + 1) = 523.

Mar 4, 2011

29. P is the mother of K; K is the sister of D; D is the father of J. How is P related to J?

Answer: 
Grand mother
Explanation:
P is the mother of K
K is the sister of D
D is the father of J.
Therefore, J is the nephew or niece of K and P is the grandmother of J.

Mar 2, 2011

28. Find the output


Program:
main()
{
    int a[5] = {5, 1, 15, 20, 25};
    int i, j, m;
    i = ++a[1];
    j = a[1]++;
    m = a[i++];
    printf("%d, %d, %d", i, j, m);
}



Ans : 3,2,15

Explanation :

Step 1int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an integer array with a size of 5 and it is initialized to
a[0] = 5a[1] = 1a[2] = 15a[3] = 20a[4] = 25 .
Step 2int i, j, m; The variable i,j,m are declared as an integer type.
Step 3i = ++a[1]; becomes i = ++1; Hence i = 2 and a[1] = 2
Step 4j = a[1]++; becomes j = 2++; Hence j = 2 and a[1] = 3.
Step 5m = a[i++]; becomes m = a[2]; Hence m = 15 and i is incremented by 1(i++ means 2++ so i=3)
Step 6printf("%d, %d, %d", i, j, m); It prints the value of the variables i, j, m
Hence the output of the program is 3, 2, 15

27. In how many ways can the letters of the word 'LEADER' be arranged?

Ans : 360


Explanation :

The word 'LEADER' contains 6 letters, namely 1L, 2E, 1A, 1D and 1R.
 Required number of ways =6!= 360.
(1!)(2!)(1!)(1!)(1!)