Monday, 25 April 2016

Find Output Of The Program


1. What is the output of the program given below ?

#include<stdio.h>
int main()
{
    enum status { pass, fail, atkt};
    enum status stud1, stud2, stud3;
    stud1 = pass;
    stud2 = atkt;
    stud3 = fail;
    printf("%d, %d, %d\n", stud1, stud2, stud3);
    return 0;
}
A. 0, 1, 2
B. 1, 2, 3
C. 0, 2, 1
D. 1, 3, 2


Answer: Option C

Explanation:

enum takes the format like {0,1,2..) so pass=0, fail=1, atkt=2

stud1 = pass (value is 0)

stud2 = atkt (value is 2)

stud3 = fail (value is 1)

Hence it prints 0, 2, 1



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

#include<stdio.h>
int main()
{
    extern int i;
    i = 20;
    printf("%d\n", sizeof(i));
    return 0;
}
A. 2
B. 4
C. vary from compiler
D. Linker Error : Undefined symbol 'i'


Answer: Option D

Explanation:

Linker Error : Undefined symbol 'i'
The statement extern int i specifies to the compiler that the memory for 'i' is allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name 'i' is available in any other program with memory space allocated for it. Hence a linker error has occurred.


3. What is the output of the program?

#include<stdio.h>
int main()
{
    extern int a;
    printf("%d\n", a);
    return 0;
}
int a=20;
A. 20
B. 0
C. Garbage Value
D. Error


Answer: Option A

Explanation:

extern int a; indicates that the variable a is defined elsewhere, usually in a separate source code module.

printf("%d\n", a); it prints the value of local variable int a = 20. Because, whenever there is a conflict between local variable and global variable, local variable gets the highest priority. So it prints 20.


4. What is the output of the program in Turbo C (in DOS 16-bit OS)?

#include<stdio.h>
int main()
{
    char *s1;
    char far *s2;
    char huge *s3;
    printf("%d, %d, %d\n", sizeof(s1), sizeof(s2), sizeof(s3));
    return 0;
}
A. 2, 4, 6
B. 4, 4, 2
C. 2, 4, 4
D. 2, 2, 2

Answer: Option C

Explanation:

Any pointer size is 2 bytes. (only 16-bit offset)
So, char *s1 = 2 bytes.
So, char far *s2; = 4 bytes.
So, char huge *s3; = 4 bytes.
A far, huge pointer has two parts: a 16-bit segment value and a 16-bit offset value.

Since C is a compiler dependent language, it may give different output in other platforms. The above program works fine in Windows (TurboC), but error in Linux (GCC Compiler).


5. What is the output of the program

#include<stdio.h>
int main()
{
    struct emp
    {
        char name[20];
        int age;
        float sal;
    };
    struct emp e = {"Tiger"};
    printf("%d, %f\n", e.age, e.sal);
    return 0;
}
A. 0, 0.000000
B. Garbage values
C. Error
D. None of above


Answer: Option A

Explanation:

When an automatic structure is partially initialized remaining elements are initialized to 0(zero).



6. What will be the output of the program?

#include<stdio.h>
int X=40;
int main()
{
    int X=20;
    printf("%d\n", X);
    return 0;
}
A. 20
B. 40
C. Error
D. No Output


Answer: Option A

Explanation:

Whenever there is conflict between a local variable and global variable, the local variable gets priority.


7.  What is the output of the program

#include<stdio.h>
int main()
{
    int x = 10, y = 20, z = 5, i;
    i = x < y < z;
    printf("%d\n", i);
    return 0;
}
A. 0
B. 1
C. Error
D. None of these


Answer: Option B

Explanation:

Since x < y turns to be TRUE it is replaced by 1. Then 1 < z is compared and to be TRUE. The 1 is assigned to i.


8. What is the output of the program

#include<stdio.h>
int main()
{
    extern int fun(float);
    int a;
    a = fun(3.14);
    printf("%d\n", a);
    return 0;
}
int fun(int aa)
{
    return (int)++aa;
}
A. 3
B. 3.14
C. 0
D. 4
E. Compile Error


Answer: Option E

Explanation:

2 Errors
1. Type mismatch in redeclaration of fun
2. Type mismatch in parameter aa



9. What is the output of the program

#include<stdio.h>
int main()
{
    int a[5] = {2, 3};
    printf("%d, %d, %d\n", a[2], a[3], a[4]);
    return 0;
}
A. Garbage Values
B. 2, 3, 3
C. 3, 2, 2
D. 0, 0, 0


Answer: Option D

Explanation:

When an automatic array is partially initialized, the remaining elements are initialized to 0.


10. What is the output of the program?

#include<stdio.h>
int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a u;
    u.ch[0] = 3;
    u.ch[1] = 2;
    printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
    return 0;
}
A. 3, 2, 515
B. 515, 2, 3
C. 3, 2, 5
D. None of these


Explanation:

printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i); It prints the value of u.ch[0] = 3, u.ch[1] = 2 and it prints the value of u.i means the value of entire union size.

So the output is 3, 2, 515.


11. In the following program how long will the for loop get executed?

#include<stdio.h>
int main()
{
    int i=5;
    for(;scanf("%s", &i); printf("%d\n", i));
    return 0;
}
A. The for loop would not get executed at all
B. The for loop would get executed only once
C. The for loop would get executed 5 times
D. The for loop would get executed infinite times


Answer: Option D

Explanation:

During the for loop execution scanf() ask input and then printf() prints that given input. This process will be continued repeatedly because, scanf() returns the number of input given, the condition is always true(user gives a input means it reurns '1').

Hence this for loop would get executed infinite times.


12. What will be the output of the program?

#include<stdio.h>
int main()
{
    int X=40;
    {
        int X=20;
        printf("%d ", X);
    }
    printf("%d\n", X);
    return 0;
}
A. 40 40
B. 20 40
C. 20
D. Error


Answer: Option B

Explanation:

In case of a conflict between a local variable and global variable, the local variable gets priority.



Friday, 22 April 2016

General Knowledge : History


1.  The title of 'Viceroy' was added to the office of the Governor-General of India for the first time in

A. 1848 AD
B. 1856 AD
C. 1858 AD
D. 1862 AD


Answer: Option C


2.  To which of the following dynasties did King Bhoja, a great patron of literature and art, belong?

A. Karkota
B. Utpala
C. Paramara
D. Gurjara Pratihara


Answer: Option C


3.  Vikramaditya, a king of Ujjain, started the Vikrama samvat in 58 BC in commemoration of his victory over

A. Indo-Greeks
B. Sakas
C. Parthinas
D. Kushanas


Answer: Option B



4.  Two of the great Mughals wrote their own memories. There were

A. Babar and Humayun
B. Humayun and Jahangir
C. Babar and Jahangir
D. Jahangir and Shahjahan


Answer: Option C


5.  To which king belongs the Lion capital at Sarnath?

A. Chandragupta
B. Ashoka
C. Kanishka
D. Harsha


Answer: Option B



6.  The use of spinning wheel (Charkha) became common during the

A. 9th Century AD
B. 10th Century AD
C. 12th Century AD
D. 14th Century AD

Answer: Option D

7.  The language of discourses of Gautama Buddha was

A. Bhojpuri
B. Magadhi
C. Pali
D. Sanskrit

Answer: Option C


8.  There were widespread risings against the British in the 1820s. Which one of the following did not revolt in the 1820s?

A. Santhals
B. Ahoms
C. Pagal Panthis
D. Ramosi


Answer: Option A


9.  Velu Thampi led a revolt against the British in state of

A. Travancore
B. Baroda
C. Hyderabad
D. Mysore

Answer: Option A

10. Under the Mountbatten Plan of 1947 the people of ___ were given the right to decide through a plebiscite whether they wished to join Pakistan or India.

A. Assam
B. Punjab
C. Bengal
D. N.W.F.P and the Sylhet district of Assam


Answer: Option D

Thursday, 21 April 2016

Botany Questions and Answers


1.  DNA structure was discovered by
 
A. Karl Land Steiner
B. Gregor Mendel
C. Watson and Crick
D. Hargobind Khorana


Ans: C


2.  Fresh foods and fruits contain more of
 
A. fats
B. vitamins
C. carbohydrates
D. proteins


Ans: B


3.  Human heart contains
 
A. 2 chambers
B. 3 chambers
C. 4 chambers
D. 6 chambers


Ans: C


4.  Which is the largest organ in human body?
 
A. lungs
B. liver
C. skin
D. heart


Ans: C



5.  Brain fever is spread to man by
 
A. mosquito
B. air
C. water
D. house fly


Ans: A


6.  The term chromosome was given by
 
A. E.G. Balibiani
B. Chargaff
C. W. Waldeyer
D. Watson and Crick


Ans: C


7.  Artificial silk is prepared from
 
A. wood pulp
B. wool
C. synthetic fibres
D. phloem fibres

Ans: C


8.   Which one of the following is a green house gas
 
A. Oxygen
B. Carbon dioxide
C. Ozone
D. Nitrogen

Ans: B



9.  Botanical name of paddy is
 
A. Tritium vulgare
B. Solanum nigrum
C. Eleusine coracana
D. Oryza sativa


Ans: D


10.  In man the number of chromosome is
 
A. 12
B. 24
C. 36
D. 46

Ans: D

Verbal Ability - Spotting Errors


Read the each sentence to find out whether there is any grammatical error in it. The error, if any will be in one part of the sentence. The letter of that part is the answer. If there is no error, the answer is 'D'. (Ignore the errors of punctuation, if any).

1. (solve as per the direction given above)

A. We discussed about the problem so thoroughly
B. on the eve of the examination
C. that I found it very easy to work it out.
D. No error.


Answer: Option A

Explanation:

We discussed the problem so thoroughly.



2. (solve as per the direction given above)

A. An Indian ship
B. laden with merchandise
C. got drowned in the Pacific Ocean.
D. No error.


Answer: Option C

Explanation:

sank in the Pacific Ocean


3. (solve as per the direction given above)

A. I could not put up in a hotel
B. because the boarding and lodging charges
C. were exorbitant.
D. No error.


Answer: Option A

Explanation:

'I could not put up at a hotel'



4. (solve as per the direction given above)

A. The Indian radio
B. which was previously controlled by the British rulers
C. is free now from the narrow vested interests.
D. No error.


Answer: Option C

Explanation:

is now free from the narrow vested interests.


5. (solve as per the direction given above)

A. If I had known
B. this yesterday
C. I will have helped him.
D. No error.


Answer: Option C

Explanation:

I would have helped him


6. (solve as per the direction given above)

A. A lot of travel delay is caused
B. due to the inefficiency and lack of good management
C. on behalf of the railways.
D. No error.


Answer: Option C

Explanation:

on the part of the railways



7. (solve as per the direction given above)

A. One of the members
B. expressed doubt if
C. the Minister was an atheist.
D. No error.


Answer: Option B

Explanation:

expressed doubt that


8. (solve as per the direction given above)

A. I have got
B. my M.Sc. degree
C. in 1988.
D. No error.


Answer: Option A

Explanation:

I got


9. (solve as per the direction given above)

A. Having received your letter
B. this morning, we are writing
C. to thank you for the same.
D. No error.

Answer: Option D


10. (solve as per the direction given above)

A. If you lend him a book
B. he will lend it to some one else
C. and never you will get it back.
D. No error.

Answer: Option C

Explanation:

and you will never get it back

Mechanical Engineering Question and Answer


1. According to principle of conservation of energy, the total momentum of a system of masses in any direction remains constant unless acted upon by an external force in that direction.

A. True
B. False

Answer: Option B


2.   The friction experienced by a body, when in motion, is known as

A. rolling friction
B. dynamic friction
C. limiting friction
D. static friction


Answer: Option B


3. Two balls of equal mass and of perfectly elastic material are lying on the floor. One of the ball with velocity v is made to struck the second ball. Both the balls after impact will move with a velocity

A. v
B. v/2
C. v/4
D. v/8


Answer: Option B


4. The term 'force' may be defined as an agent which produces or tends to produce, destroys or tends to destroy motion.

A. Agree
B. Disagree


Answer: Option A



5. The coefficient of restitution for elastic bodies is one.

A. Correct
B. Incorrect

Answer: Option B

6. The velocity ratio in case of an inclined plane inclined at angle θ to the horizontal and weight being pulled up the inclined plane by vertical effort is

A. sin θ
B. cos θ
C. tan θ
D. cosec θ


Answer: Option A


7. The range of projectile on a downward inclined plane is __________ the range on upward inclined plane for the same velocity of projection and angle of projection.

A. less than
B. more than
C. equal to


Answer: Option B


8.  The angle of inclination of a vehicle when moving along a circular path __________ upon its mass.

A. depends
B. does not depend


Answer: Option B


9. A body of weight W is required to move up on rough inclined plane whose angle of inclination with the horizontal is α. The effort applied parallel to the plane is given by(where μ = tanφ = Coefficient of friction between the plane and the body.)

A. P = W tanα
B. P = W tan(α + φ)
C. P = W (sinα + μcosα)
D. P = W (cosα + μsinα)


Answer: Option C


10. If the resultant of two equal forces has the same magnitude as either of the forces, then the angle between the two forces is

A. 30°
B. 60°
C. 90°
D. 120°


Answer: Option D



C++ - Constants Questions and Answers


1.  The constants are also called as
A. const
B. preprocessor
C. literals
D. none of the mentioned


Answer: Option C


2. What are the parts of the literal constants?
A. integer numerals
B. floating-point numerals
C. strings and boolean values
D. all of the mentioned


Answer: Option D

Explanation:

Because these are the types used to declare variables and so these can be declared as constants.


3.  How the constants are declared?
A. const keyword
B. #define preprocessor
C. both a and b
D. None of the mentioned

Answer: Option C

Explanation:

The const will declare with a specific type values and #define is used to declare user definied constants.


4.  What is the output of this program?
#include
using namespace std;
int main()
{
int  const  p = 5;
cout << ++p;
return 0;
}
A. 5
B. 6
C. Error
D. None of the mentioned

Answer: Option C

Explanation:

We cannot modify a constant integer value.


5.  What is the output of this program?
#include < iostream >
using namespace std;
#define PI 3.14159
int main ()
{
float r = 2;
float circle;
circle = 2 * PI * r;
cout << circle;
return 0;
}

A. 12.566
B. 13.566
C. 10
D. compile time error


Answer: Option A

Explanation:

In this program, we are finding the area of the circle by using concern formula.


6.  Which of the following statement is true about preprocessor directives?
A. hese are lines read and processed by the preprocessor
B. They do not produce any code by themselves
C. These must be written on their own line
D. They end with a semicolon


Answer: Option D



7.  Regarding following statement which of the statements is true?
     const int a = 100;
A. Declares a variable a with 100 as its initial value  
B. Declares a construction a with 100 as its initial value
C. Declares a constant a whose value will be 100
D. Constructs an integer type variable with a as identifier and 100 as value


Answer: Option C

Explanation:

Because the const is used to declare non-changable values only.


8.   The difference between x and ‘x’ is
A. The first one refers to a variable whose identifier is x and the second one refers to the character constant x
B. The first one is a character constant x and second one is the string literal x
C. Both are same
D. None of the mentioned


Answer: Option A

Explanation:

The first one refers to a variable whose identifier is x and the second one refers to the character constant x


9.   How to declare a wide character in string literal?
A. L prefix
B. l prefix
C. W prefix
D. none of the mentioned


Answer: Option A

Explanation:

It can turn this as wide character instead of narrow characters.

Number Series - Questions and Answers


1.   Look at this series: 2, 1, (1/2), (1/4), ... What number should come next?

A.   (1/3)
B.   (1/8)
C.   (2/8)
D.   (1/16)


Answer: Option B

Explanation:

This is a simple division series; each number is one-half of the previous number. In other terms to say, the number is divided by 2 successively to get the next result.
4/2 = 2
2/2 = 1
1/2 = 1/2
(1/2)/2 = 1/4
(1/4)/2 = 1/8 and so on


2.  Look at this series: 7, 10, 8, 11, 9, 12, ... What number should come next?

A.   7
B.   10
C.   12
D.   13



Answer: Option B

Explanation:

This is a simple alternating addition and subtraction series. In the first pattern, 3 is added; in the second, 2 is subtracted



3.  Look at this series: 36, 34, 30, 28, 24, ... What number should come next?

A.   20
B.   22
C.   23
D.   26


Answer: Option B

Explanation:

This is an alternating number subtraction series. First, 2 is subtracted, then 4, then 2, and so on


4. Look at this series: 22, 21, 23, 22, 24, 23, ... What number should come next?

A.   22
B.   24
C.   25
D.   26


Answer: Option C

Explanation:

In this simple alternating subtraction and addition series; 1 is subtracted, then 2 is added, and so on.


5. Look at this series: 53, 53, 40, 40, 27, 27, ... What number should come next?

A.   12
B.   14
C.   27
D.   53


Answer: Option B

Explanation:

In this series, each number is repeated, then 13 is subtracted to arrive at the next number.


6.  Look at this series: 21, 9, 21, 11, 21, 13, 21, ... What number should come next?

A.   14
B.   15
C.   21
D.   23


Answer: Option B

Explanation:

In this alternating repetition series, the random number 21 is interpolated every other number into an otherwise simple addition series that increases by 2, beginning with the number 9.


7.  Look at this series: 58, 52, 46, 40, 34, ... What number should come next?

A.   26
B.   28
C.   30
D.   32


Answer: Option B

Explanation:

This is a simple subtraction series. Each number is 6 less than the previous number.


8.  Look at this series: 3, 4, 7, 8, 11, 12, ... What number should come next?

A.   7
B.   10
C.   14
D.   15


Answer: Option D

Explanation:

This alternating addition series begins with 3; then 1 is added to give 4; then 3 is added to give 7; then 1 is added, and so on.


9.  Look at this series: 8, 22, 8, 28, 8, ... What number should come next?

A.   9
B.   29
C.   32
D.   34


Answer: Option D

Explanation:

This is a simple addition series with a random number, 8, interpolated as every other number. In the series, 6 is added to each number except 8, to arrive at the next number.


10.  Look at this series: 31, 29, 24, 22, 17, ... What number should come next?

A.   15
B.   14
C.   13
D.   12


Answer: Option A

Explanation:

This is a simple alternating subtraction series, which subtracts 2, then 5.