Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Multiple choice question for engineering

Set 1

1. The number of digits present after decimal in float is________
a) 1
b) 3
c) 6
d) 16

View Answer

Answer: c

2. Which among the following is never possible as an output for float?
a) 3.666666
b) 3.666
c) 3
d) None of the mentioned

View Answer

Answer: d

3. In a 32-bit compiler, which 2 types have same size?
a) char and short
b) short and int
c) int and float
d) float and double

View Answer

Answer: c

4. What is the size of float in a 32-bit compiler?
a) 1
b) 2
c) 4
d) 8

View Answer

Answer: c

5. Loss in precision occurs for typecasting from____________
a) char to short
b) float to double
c) long to float
d) float to int

View Answer

Answer: d

6. For union

  1. 	union temp
  2.     {
  3.         char a;
  4.         int b;
  5.         float c;
  6.     };

The size is decided by:
a) char
b) int
c) float
d) both int and float

View Answer

Answer: d

7. %f access specifier is used for
a) Strings
b) Integral types
c) Floating type
d) All of the mentioned

View Answer

Answer: c

8. Select the odd one out with respect to type?
a) char
b) int
c) long
d) float

View Answer

Answer: d

Set 2

1. What is the output of this C code?

  1.     #include <stdio.h>
  2.     printf("%.0f", 2.89);

a) 2.890000
b) 2.89
c) 2
d) 3

View Answer

Answer: d

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         float a = 2.455555555555;
  5.         printf("%f", a);
  6.     }

a) 2.455555
b) 2.455556
c) 2.456
d) 2.46

View Answer

Answer: a

3. Which of the following % operation is invalid?
a) 2 % 4;
b) 2 % 4l;
c) 2 % 4f;
d) Both 2 % 4l; and 2 % 4f;

View Answer

Answer: c

4. Which data type is suitable for storing a number like?
    10.0000000001
a) int
b) float
c) double
d) both float and double

View Answer

Answer: c

5. Modulus for float could be achieved by?
a) a % b
b) modulus(a, b);
c) fmod(a, b);
d) mod(a, b);

View Answer

Answer: c

6. Predict the data type of the following mathematical operation?
    2 * 9 + 3 / 2 . 0
a) int
b) long
c) float
d) double

View Answer

Answer: d

7. %lf is used to display
a) float
b) long float
c) double
d) all of the mentioned

View Answer

Answer: c

Set 3

1. The function srand(unsigned)
a) Sets the seed for rand
b) Doesn’t exist
c) Is an error
d) None of the mentioned

View Answer

Answer: a

2. Which is the best way to generate numbers between 0 to 99?
a) rand()-100
b) rand()%100
c) rand(100)
d) srand(100)

View Answer

Answer: b

3. The correct way to generate numbers between minimum and maximum(inclusive) is _________________
a) minimum + (rand() % (maximum – minimum));
b) minimum + (rand() % (maximum – minimum + 1));
c) minimum * (rand() % (maximum – minimum))
d) minimum – (rand() % (maximum+minimum));

View Answer

Answer: b

4. rand() and srand() functions are used
a) To find sqrt
b) For and operations
c) For or operations
d) To generate random numbers

View Answer

Answer: d

5. What is the return type of rand() function?
a) short
b) int
c) long
d) double

View Answer

Answer: b

6. Which of the following can be used for random number generation?
a) random()
b) rnd()
c) rndm()
d) none of the mentioned

View Answer

Answer: a

7. Which of the following snippet will effectively generate random numbers?
a) rand();
b) rand(10);
c) rand(time(NULL));
d) all of the mentioned

View Answer

Answer: a

8. Which among the following is correct function call for rand and random?
a) rand() and random();
b) rand() and random(1);
c) rand(1) and random(1);
d) rand(1) and random();

View Answer

Answer: a

9. For the function call time(), what type of parameter is accepted?
a) int
b) int *
c) time_t
d) time_t *

View Answer

Answer: d

Set 4

1. What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes

View Answer

Answer: c

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     printf("%d", sizeof('a'));

a) 1
b) 2
c) 4
d) None of the mentioned

View Answer

Answer: c

3. Size of an array can be evaluated by:
    (Assuming array declaration int a[10];)
a) sizeof(a);
b) sizeof(*a);
c) sizeof(a[10]);
d) 10 * sizeof(a);

View Answer

Answer: a

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     union temp
  3.     {
  4.         char a;
  5.         char b;
  6.         int c;
  7.     }t;
  8.     int main()
  9.     {
  10.         printf("%d", sizeof(t));
  11.         return 0;
  12.     }

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

View Answer

Answer: c

5. Which of the following is not an operator in C?
a) ,
b) sizeof()
c) ~
d) None of the mentioned

View Answer

Answer: d

6. Which among the following has the highest precedence?
a) &
b) <<
c) sizeof()
d) &&

View Answer

Answer: c

7. The sizeof(void) in a 32-bit C is_____
a) 0
b) 1
c) 2
d) 4

View Answer

Answer: b

8. What type of value does sizeof return?
a) char
b) short
c) unsigned int
d) long

View Answer

Answer: c

Set 5

1. Which among the following is never possible in C when members are different in a structure and union?
    //Let P be a structure
    //Let Q be a union
a) sizeof(P) is greater than sizeof(Q)
b) sizeof(P) is less than sizeof(Q)
c) sizeof(P) is equal to sizeof(Q)
d) none of the mentioned

View Answer

Answer: d

2. Which among the following is never possible in C when members in a structure are same as that in a union?
    //Let P be a structure
    //Let Q be a union
a) sizeof(P) is greater than sizeof(Q)
b) sizeof(P) is equal to sizeof(Q)
c) sizeof(P) is less than to sizeof(Q)
d) none of the mentioned

View Answer

Answer: c

3. What will be the size of the following structure?

  1.     #include <stdio.h>
  2.     struct temp
  3.     {
  4.         int a[10];
  5.         char p;
  6.     };

a) 5
b) 11
c) 41
d) 44

View Answer

Answer: d

4. Comment on the output of following C program?

  1.     #include <stdio.h>
  2.     main()
  3.     {
  4.         int a = 1;
  5.         printf("size of a is %d, ", sizeof(++a));
  6.         printf("value of a is %d", a);
  7.     };

a) size of a is 4, value of a is 1
b) size of a is 4, value of a is 2
c) size of a is 2, value of a is 2
d) size of a is 2, value of a is 2

View Answer

Answer: a

5. Which among the following is right?
a) sizeof(struct stemp*) > sizeof(union utemp*) > sizeof(char *)
b) sizeof(struct stemp*) < sizeof(union utemp*) < sizeof(char *)
c) sizeof(struct stemp*) = sizeof(union utemp*) = sizeof(char *)
d) the order Depends on the compiler

View Answer

Answer: c

6. Comment on the following C code?

  1.     #include <stdio.h>
  2.     printf("%d", sizeof(strlen("HELLOWORLD")));

a) Output, 4
b) Output, 10
c) Output, 16
d) Error, sizeof cannot evaluate size of a function.

View Answer

Answer: a

7. Which of the following cannot be used inside sizeof?
a) pointers
b) functions
c) macro definition
d) none of the mentioned

View Answer

Answer: d

8. Comment on the following C code?

  1.     #include <stdio.h>
  2.     (sizeof double = 8, float = 4, void = 1)
  3.     #define PI 3.14
  4.     int main()
  5.     {
  6.         printf("%d", sizeof(PI));
  7.     }

a) Output is 8
b) Output is 4
c) Output is 1
d) Error, we can’t use sizeof on macro-definitions

View Answer

Answer: a

.woocommerce-message { background-color: #98C391 !important; }