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-10. For the given inorganic chemical reaction
HCl (aq) + NaOH (aq) → NaCl (aq) + H2O (l)
Molecular weights of the species HCl, NaOH, NaCl and H2O are 36.5, 40, 58.5 and 18 gms respectively.
1. For producing 1 mole of NaCl , how many moles of NaOH are required? (Consider HCl in excess)
a) 1
b) 4
c) 5
d) 6.5

View Answer

Answer: a [Reason:] 1 mole of NaCl is equivalent to 1 mole of NaOH.

2. For producing 1 mole of NaCl , how many moles of HCl are required? (Consider NaOH in excess)
a) 1
b) 4
c) 5
d) 6.5

View Answer

Answer: a [Reason:] 1 mole of NaCl is equivalent to 1 mole of HCl.

3. For producing 1 mole of H2O, how many moles of NaOH are required? (Consider HCl in excess)
a) 1
b) 4
c) 5
d) 6.5

View Answer

Answer: a [Reason:] 1 mole of H2O is equivalent to 1 mole of NaOH.

4. For producing 1 mole of H2O, how many moles of HCl are required? (Consider NaOH in excess)
a) 1
b) 4
c) 5
d) 6.5

View Answer

Answer: a [Reason:] 1 mole of HCl is equivalent to 1 mole of H2O.

5. If HCl is present in excess and the amount of NaOH is doubled, number of moles of NaCl will be ____________
a) Doubled
b) Half
c) Four times
d) None of the mentioned

View Answer

Answer: a [Reason:] 1 mole of NaOH is equivalent to 1 mole of NaCl.

6. If HCl is present in excess and the amount of NaOH is doubled, number of moles of H2O will be ____________
a) Doubled
b) Half
c) Four times
d) None of the mentioned

View Answer

Answer: a [Reason:] 1 mole of HCl is equivalent to 1 mole of NaOH.

7. How many moles of NaCl can be produced with 73 gms of HCl? (Consider NaOH in excess)
a) 1
b) 2
c) 3
d) None of the mentioned

View Answer

Answer: b [Reason:] 1 mole of NaCl is equivalent to 36.5 gms of HCl.

8. How many moles of H2O can be produced with 73 gms of HCl? (Consider NaOH in excess)
a) 1
b) 2
c) 3
d) None of the mentioned

View Answer

Answer: b [Reason:] 1 mole of H2O is equivalent to 36.5 gms of HCl.

9. How many gms of NaCl can be produced with 40 gms of NaOH? (Consider HCl in excess)
a) 50.8
b) 58.5
c) 60.2
d) None of the mentioned

View Answer

Answer: b [Reason:] 58.5 gms of NaCl is equivalent to 40 gms of NaOH.

10. How many gms of H2O can be produced with 40 gms of NaOH? (Consider HCl in excess)
a) 18
b) 36
c) 54
d) None of the mentioned

View Answer

Answer: a [Reason:] 18 gms of H2O is equivalent to 40 gms of NaOH.

Set 2

1. Where are allocators used?
a) Allocation of memory
b) Deallocation of memory
c) Used for pointers
d) Both Allocation & Deallocation of memory

View Answer

Answer: d [Reason:] Allocators handle all the request for allocation and deallocation of memory for the container.

2. Where are allocators implemented?
a) Template library
b) Standard library
c) C++ code library
d) None of the mentioned

View Answer

Answer: b [Reason:] Allocators are implemented in C++ standard library but it is used for C++ template library.

3. Which operator is used to allocate the memory?
a) =
b) +
c) new
d) free

View Answer

Answer: c [Reason:] The default allocator uses operator new to allocate memory.

4. What is the output of this program?

  1.     #include <iostream>
  2.     #include <memory>
  3.     #include <algorithm>
  4.     using namespace std;
  5.     int main ()
  6.     {
  7.         int numbers[] = {1, 5, 4, 5};
  8.         pair <int*, ptrdiff_t> result = get_temporary_buffer<int>(4);
  9.         if (result.second > 0)
  10.         {
  11.             uninitialized_copy (numbers, numbers + result.second, result.first);
  12.             sort (result.first, result.first + result.second);
  13.             for (int i = 0; i < result.second; i++)
  14.                 cout << result.first[i] << " ";
  15.             return_temporary_buffer (result.first);
  16.         }
  17.         return 0;
  18.     }

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

View Answer

Answer: c [Reason:] In this program, We are sorting the array by using the allocator. Output: $ g++ all.cpp $ a.out 1 4 5 5

5. What is the output of this program?

  1.     #include <iostream>
  2.     #include <memory>
  3.     #include <string>
  4.     using namespace std;
  5.     int main ()
  6.     {
  7.         string numbers[] = {"steve", "jobs"};
  8.         pair <string*, ptrdiff_t> result = get_temporary_buffer<string>(2);
  9.         if (result.second>0) 
  10.         {
  11.             uninitialized_copy ( numbers, numbers + result.second, result.first );
  12.             for (int i = 0; i < result.second; i++)
  13.                 cout << result.first[i] << " ";
  14.             return_temporary_buffer(result.first);
  15.         }
  16.         return 0;
  17.     }

a) steve
b) jobs
c) jobs steve
d) steve jobs

View Answer

Answer: d [Reason:] In this program, We are storing the string and retrieving the string by using get_temporary_method. Output: $ g++ all1.cpp $ a.out steve jobs

6. What is the output of this program?

  1.     #include <iostream>
  2.     #include <memory>
  3.     #include <string>
  4.     using namespace std;
  5.     int main () 
  6.     {
  7.         pair <string*, ptrdiff_t>
  8.        result = get_temporary_buffer<string>(3);
  9.         if (result.second > 0)
  10.         {
  11.             uninitialized_fill ( result.first, result.first + result.second, 
  12.             "Hai" );
  13.             for (int i=0; i<result.second; i++)
  14.                 cout << result.first[i] ;
  15.             return_temporary_buffer(result.first);
  16.         }
  17.         return 0;
  18.     }

a) Hai
b) HaiHai
c) HaiHaiHai
d) None of the mentioned

View Answer

Answer: c [Reason:] In this program, We storing the string in the string buffer and then we are printing it. Output: $ g++ all2.cpp $ a.out HaiHaiHai

7. Which operator is used to deallocate the memory?
a) destroy
b) free
c) empty
d) none of the mentioned

View Answer

Answer: b

8. Which header file is used to manipulate the allocater?
a) allocater
b) memory
c) object
d) none of the mentioned

View Answer

Answer: b [Reason:] Because all the memory allocation and deallocation libraries are declared in .

9. What is the use of reference member type in allocator?
a) Point to an element
b) Quantities of element
c) Reference to an element
d) None of the mentioned

View Answer

Answer: c

10. What is the correct syntax for declaring an allocator?
a) template < class T > class allocator;
b) template < class T > class;
c) template class allocator;
d) None of the mentioned

View Answer

Answer: a [Reason:] It is a type of syntax for declaring the allocater.

Set 3

1. Which operator is used for input stream?
a) >
b) >>
c) <
d) <<

View Answer

Answer: b [Reason:] The operator of extraction is >> and it is used on the standard input stream.

2. Where does a cin stops it extraction of data?
a) By seeing a blankspace
b) By seeing (
c) By seeing a blankspace & (
d) None of the mentioned

View Answer

Answer: a [Reason:] cin will stop its extraction when it encounters a blank space.

3. Which is used to get the input during runtime?
a) cout
b) cin
c) coi
d) none of the mentioned

View Answer

Answer: b [Reason:] cin is mainly used to get the input during the runtime.

4. What is the output of this program?

  1.     #include <iostream>
  2.     using namespace std;
  3.     int main ()
  4.     {
  5.         int i;
  6.         cout << "Please enter an integer value: ";
  7.         cin >> i + 4;
  8.         return 0;
  9.     }

a) 73
b) your value + 4
c) Error
d) None of the mentioned

View Answer

Answer: c [Reason:] We are not allowed to do addition operation on cin.

5. What is the output of this program?

  1.     #include <iostream>
  2.     #include <string>
  3.     #include <sstream>
  4.     using namespace std;
  5.     int main ()
  6.     {
  7.         string mystr;
  8.         float price = 0;
  9.         int quantity = 0;
  10.         cout << "Enter price: ";
  11.         getline (cin, mystr);
  12.         stringstream(mystr) >> price;
  13.         cout << "Enter quantity: ";
  14.         getline (cin, mystr);
  15.         stringstream(mystr) >> quantity;
  16.         cout << "Total price: " << price * quantity << endl;
  17.         return 0;
  18.     }

a) 50
b) Depends on value you enter
c) Error
d) None of the mentioned

View Answer

Answer: b [Reason:] In this program, We are getting the input on runtime and manipulating the value. Output: $ g++ inp.cpp $ a.out Enter price: 3 Enter quantity: 4 Total price: 12

6. What is the output of this program?

  1.     #include <iostream>
  2.     #include <ios>
  3.     #include <istream>
  4.     #include <limits>
  5.     using namespace std;
  6.     template <typename CharT>
  7.     void ignore_line ( basic_istream<CharT>& in )
  8.     {
  9.         in.ignore ( numeric_limits<streamsize> :: max(), in.widen ( 'n' ) );
  10.     }
  11.     int main()
  12.     {
  13.         cout << "First input: ";
  14.         cin.get();
  15.         cout << "Clearing cin.n";
  16.         cin.clear();
  17.         ignore_line ( cin );
  18.         cout << "All done.n";
  19.     }

a) First input
b) Clearing cin
c) Error
d) None of the mentioned

View Answer

Answer: d [Reason:] In this program, We are getting the input and clearing all the values. Output: $ g++ inp1.cpp $ a.out First input: 4 Clearing cin. All done.

7. What is the output of this program?

  1.     #include <iostream>
  2.     using namespace std;
  3.     int main( )
  4.     {
  5.         char line[100];
  6.         cin.getline( line, 100, 't' );
  7.         cout << line;
  8.         return 0;
  9.     }

a) 100
b) t
c) It will print what we enter till character t is encountered in the input data
d) None of the mentioned

View Answer

Answer: c [Reason:] The program will store all strings entered and will print them only when the character ‘t’ is encountered.

Input >> coding Input >> is fun Input >> t

Output: coding is fun

8. How many parameters are there in getline function?
a) 1
b) 2
c) 2 or 3
d) 3

View Answer

Answer: c [Reason:] There are two or three parameters in getline() function. They are a pointer to an array of characters and maximum number of characters and an optional delimiter.

9. What can be used to input a string with blankspace?
a) inline
b) getline
c) putline
d) none of the mentioned

View Answer

Answer: b [Reason:] If a user wants to input a sentence with blankspaces, then he may use the function getline.

10. When will the cin can start proceessing of input?
a) After pressing return key
b) BY pressing blankspace
c) After pressing return key & BY pressing blankspace
d) None of the mentioned

View Answer

Answer: a

Set 4

1. Which one is always faster in writing on C++?
a) Writing to a file
b) Writing to memory
c) Reading from the network
d) None of the mentioned

View Answer

Answer: b [Reason:] For the stand of file operations, writing to memory (RAM) is always faster than writing to the file on the disk directly.

2. How many tests are available in read and write operations?
a) 1
b) 2
c) 3
d) 4

View Answer

Answer: b [Reason:] There are two types of read and write tests. They are throughput in random reads and throughput in contiguous reads.

3. What will act as a intermediate between i/o operations and physical file?
a) Memory
b) Ram
c) Stream buffer
d) None of the mentioned

View Answer

Answer: c [Reason:] A stream buffer is a block of data that acts as intermediary between the i/o operations and the physical file associated to the stream.

4. What is the output of this program in text files?

  1.     #include <stdio.h>
  2.     int main ()
  3.     {
  4.         char buffer[BUFSIZ];
  5.         FILE *p1, *p2;
  6.         p1 = fopen ("myfile.txt", "w");
  7.         p2 = fopen ("myfile2.txt", "a");
  8.         setbuf ( p1 , buffer );
  9.         fputs ("Buffered stream", p1);
  10.         fflush (p1);
  11.         setbuf ( p2 , NULL );
  12.         fputs ("Unbuffered stream", p2);
  13.         fclose (p1);
  14.         fclose (p2);
  15.         return 0;
  16.     }

a) Buffered stream
b) Unbuffered stream
c) Error
d) Buffered & Unbuffered stream

View Answer

Answer: d [Reason:] In this program, the fopen will create the file and send the text to both of the files. Output: $ g++ buf.cpp $ a.out “Buffered stream” in myfile.txt “Unbuffered stream” in myfile2.txt

5. What is the output of this program?

  1.     #include <stdio.h>
  2.     int main ()
  3.     {
  4.         FILE * p;
  5.         long size;
  6.         p = fopen ("test.txt", "rb");
  7.         if (p == NULL) 
  8.             perror ("Error opening file");
  9.         else
  10.         {
  11.             fseek (p, 0, SEEK_END); 
  12.             size = ftell (p);
  13.             fclose (p);
  14.             printf (" %ldn", size);
  15.         }
  16.         return 0;
  17.     }

a) 10
b) 20
c) 5
d) Depends upon the file

View Answer

Answer: d [Reason:] This program will return the size of the file in bytes. Output: $ g++ buf1.cpp $ a.out 20

6. What is the output of this program in the file?

  1.     #include <stdio.h>
  2.     int main ()
  3.     {
  4.         freopen ("myfile.txt", "w", stdout);
  5.         printf ("This sentence is redirected to a file");
  6.         fclose (stdout);
  7.         return 0;
  8.     }

a) This sentence
b) This sentence is redirected
c) This sentence is redirected to a file
d) None of the mentioned

View Answer

Answer: c [Reason:] In this program, We are sending the text to the file by opening the file using the function freopen. Output: $ g++ buf2.cpp $ a.out This sentence is redirected to a file

7. What is the output of this program?

  1.     #include <stdio.h>
  2.     int main ()
  3.     {
  4.         int n;
  5.         FILE * p;
  6.         char buffer [5];
  7.         p = fopen ("myfile.txt", "w+");
  8.         for ( n = 'A' ; n <= 'D' ; n++)
  9.         fputc ( n, p);
  10.         rewind (p);
  11.         fread (buffer, 1, 5, p);
  12.         fclose (p);
  13.         buffer[3] = ' ';
  14.         puts (buffer);
  15.         return 0;
  16.     }

a) ABCD
b) ABC
c) ABCDE
d) None of the mentioned

View Answer

Answer: b [Reason:] In this program, We are setting the buffer size upto 3 only, So it is printing ABC. Output: $ g++ buf3.cpp $ a.out ABC

8. What is the output of this program in the text file?

  1.     #include <stdio.h>
  2.     int main ()
  3.     {
  4.         FILE * p;
  5.         char buffer[] = { 'x' , 'y' , 'z' };
  6.         p = fopen ( "myfile.txt" , "wb" );
  7.         fwrite (buffer , 1 , sizeof(buffer) , p );
  8.         fclose (p);
  9.         return 0;
  10.     }

a) xyz
b) zyx
c) yxz
d) none of the mentioned

View Answer

Answer: a [Reason:] In this program, We are writing into the file by using the function fwrite. Output: $ g++ buf4.cpp $ a.out xyz

9. By using which function does the buffer are automatically flushed?
a) fopen
b) copy
c) compare
d) fclose

View Answer

Answer: d

10. How many parameters are available in the function setbuf?
a) 1
b) 2
c) 3
d) 4

View Answer

Answer: b [Reason:] There are two parameters that are used in setbuf. They are stream and buffer.

Set 5

1. Where are standard C libraries defined in C++?
a) Container
b) std namespace
c) list
d) None of the mentioned

View Answer

Answer: b [Reason:] Every element of the c library is defined within the std namespace.

2. Which of the following have their changes in their declaration related to constness of parameter?
a) strchr
b) string
c) memory
d) none of the mentioned

View Answer

Answer: a [Reason:] These are the items which will have their change in declaration related to constness of parameter. They are strchr, strpbrk, strrchr, strstr, memchr.

3. How many elements does a floating point number is composed of?
a) 1
b) 2
c) 3
d) 4

View Answer

Answer: d [Reason:] The floating point number composed of four elements. They are sign, Base, Significand and Exponent.

4. What is the output of this program?

  1.     #include <stdio.h>    
  2.     #include <stdlib.h>
  3.     int main ()
  4.     {
  5.         char s[] = "365.24 29.53";
  6.         char* p;
  7.         double d1, d2;
  8.         d1 = strtod (s, &p);
  9.         d2 = strtod (p, NULL);
  10.         printf ("%.2fn", d1/d2);
  11.         return 0;
  12.     }

a) 12
b) 12.37
c) 13
d) None of the mentioned

View Answer

Answer: b [Reason:] In this program, We are calculating the double value by using the floating point number and we are using the function strtod. Output: $ g++ cinc.cpp $ a.out 12.37

5. What is the output of this program?

  1.     #include <stdio.h>
  2.     #include <stdlib.h>
  3.     int compareints (const void * a, const void * b)
  4.     {
  5.         return ( *(int*)a - *(int*)b );
  6.     }
  7.     int values[] = { 50, 20, 60, 40, 10, 30 };
  8.     int main ()
  9.     {
  10.         int * p;
  11.         int key = 40;
  12.         qsort(values, 6, sizeof (int), compareints);
  13.         p = (int*) bsearch (&key, values, 6, sizeof (int), compareints);
  14.         if (p != NULL)
  15.         printf ("%dn",*p);
  16.         return 0;
  17.     }

a) 10
b) 20
c) 40
d) 30

View Answer

Answer: c [Reason:] In this program, We are searching for the element and then we are printing it. Output: $ g++ cinc1.cpp $ a.out 40

6. What is the output of this program?

  1.     #include <stdio.h>    
  2.     #include <stdlib.h>   
  3.     int main ()
  4.     {
  5.         int n, m;
  6.         n = abs(23);
  7.         m = abs(-11);
  8.         printf ("%d", n);
  9.         printf ("%d", m);
  10.         return 0;
  11.     }

a) 23-11
b) 1123
c) 2311
d) None of the mentioned

View Answer

Answer: c [Reason:] In this program, We are finding the absolute value of the n. Output: $ g++ cinc2.cpp $ a.out 2311

7. What is the output of this program?

  1.     #include <stdio.h>
  2.     #include <math.h>
  3.     int main ()
  4.     {
  5.         printf ("The value of -3.1416 is %lfn", fabs (-3.1416));
  6.         return 0;
  7.     }

a) 3.1416
b) -3.1416
c) -3.141600
d) 3.141600

View Answer

Answer: d [Reason:] In this program, We are finding the absolute value of a floating point value. Output: $ g++ cinc3.cpp $ a.out 3.141600

8. What is the output of this program?

  1.     #include <stdio.h>
  2.     #include <stdlib.h>
  3.     int main ()
  4.     {
  5.         div_t divresult;
  6.  
  7.         divresult = div (38, 5);
  8.         printf ("%dn", divresult.rem);
  9.         return 0;
  10.     }

a) 7
b) 3
c) 4
d) None of the mentioned

View Answer

Answer: b [Reason:] In this program, We are finding the remainder of a number by using div function. Output: $ g++ cinc4.cpp $ a.out 3

9. How does the limits.h header file can be represented in C++?
a) limits
b) limit
c) climits
d) none of the mentioned

View Answer

Answer: c

10. Pick out the correct syntax of the header file that can be used with C++.
a) #include <float>
b) #include <float.h>
c) Both #include <float> & #include <float.h>
d) None of the mentioned

View Answer

Answer: b [Reason:] The C header file that is ending with h can only be used in C++.