logo
  • Home
  • About
  • Training
  • Programming
  • CS
  • IT
  • IS
  • ECE
  • EEE
  • EE
  • Civil
  • Mechanical
  • Chemical
  • Metallurgy
  • Instrumentation
  • Aeronautical
  • Aerospace
  • Biotechnology
  • Agriculture
  • MCA
  • BCA
  • Internship
  • Contact

C++ Multiple Choice Questions | MCQs | Quiz

C++ Interview Questions and Answers
Pratice C++ questions and answers for interviews, campus placements, online tests, aptitude tests, quizzes and competitive exams.

Get Started

•   Types
•   Booleans
•   Character Types
•   Integer Types
•   Floating Point Types
•   Sizes
•   Void
•   Enumerations
•   Declaration
•   Pointers
•   Arrays
•   Pointers into Arrays
•   Constants
•   References
•   Pointer to Void
•   Structures
•   Operators
•   Statements
•   Comments & Indentation
•   Function Declarations
•   Argument Passing
•   Value Return
•   Overloaded Function
•   Default Arguments
•   Unspecified Arguments
•   Pointer to Function
•   Macros
•   Modularization
•   Namespaces
•   Exceptions
•   Linkage
•   Header Files Usage
•   Classes
•   User Defined Types
•   Objects
•   Operator Functions
•   Complex Number Type
•   Conversion Operators
•   Friends
•   Large Objects
•   Essential Operators
•   Subscripting
•   Function Call
•   Dereferencing
•   Increment & Decrement
•   String Class
•   Derived Classes
•   Abstract Classes
•   Class Hierarchies
•   Abstract Classes
•   Simple String Template
•   Function Templates
•   Policy Usage Template
•   Specialization
•   Derivation & Templates
•   Error Handling
•   Grouping of Exceptions
•   Catching Exceptions
•   Resource Management
•   Exceptions Not Errors
•   Exception Specifications
•   Uncaught Exceptions
•   Exceptions & Efficiency
•   Error Handling Alternatives
•   Standard Exceptions
•   Class Hierarchies
•   Multiple Inheritance
•   Access Control
•   Run Time Type
•   Pointers to Members
•   Free Store
•   Standard Library Design
•   Container Design
•   Vector
•   Sequences
•   Sequence Adapters
•   Associative Containers
•   Almost Containers
•   Defining a New Container
•   Library Algorithms
•   Sequences / Containers
•   Function Objects
•   Nonmodifying Algorithms
•   Modifying Algorithms
•   Stored Sequences
•   Heaps
•   Min and Max
•   Permutations
•   C Style Algorithms
•   Iterators & Sequences
•   Checked Iterators
•   Allocators
•   String Characters
•   Basic String
•   C Standard Library
•   Output Stream
•   Input Stream
•   Formatting
•   File & String Streams
•   Buffering
•   Locale
•   C Input Output
•   Numeric Limits
•   Mathematical Functions
•   Vector Arithmetic
•   Numeric Algorithms
•   Random Numbers

Best Reference Books

C++ Books
« Prev Page
Next Page »

C++ Programming Questions and Answers – C Standard Library

Posted on November 13, 2012 by Manish
This section on C++ quiz focuses on “C Standard Library”. One shall practice these online quizzes to improve their C++ programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C++ programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C++ quiz comes with detailed explanation of the answers which helps in better understanding of C++ concepts.

Here is a listing of C++ quiz on “C Standard Library” along with answers, explanations and/or solutions:

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
Explanation: 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
Explanation: 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
Explanation: 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 ("%.2f\n", d1/d2);
  11.         return 0;
  12.     }

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

Answer: b
Explanation: 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 ("%d\n",*p);
  16.         return 0;
  17.     }

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

Answer: c
Explanation: 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
Explanation: 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 %lf\n", fabs (-3.1416));
  6.         return 0;
  7.     }

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

Answer: d
Explanation: 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 ("%d\n", divresult.rem);
  9.         return 0;
  10.     }

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

Answer: b
Explanation: 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
Explanation: None.

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
Explanation: The C header file that is ending with h can only be used in C++.

Sanfoundry Global Education & Learning Series – C++ Programming Language.

Here’s the list of Best Reference Books in C++ Programming Language.

To practice all features of C++ programming language, here is complete set on 1000+ Multiple Choice Questions and Answers on C++.

« Prev Page - C++ Programming Questions and Answers – Basic String
» Next Page - C++ Programming Questions and Answers – Output Stream
« C++ Programming Questions and Answers – Basic String
C++ Programming Questions and Answers – Output Stream »

Deep Dive @ Sanfoundry:

  1. C Programming Examples
  2. C Programming Examples on Data-Structures
  3. C++ Programming Examples on STL
  4. Ruby Programming Questions and Answers
  5. C# Programming Examples on Matrix
  6. C# Programming Examples on Networking
  7. Java Algorithms, Problems & Programming Examples
  8. R Programming Questions and Answers
  9. C++ Algorithms, Problems & Programming Examples
  10. C Algorithms, Problems & Programming Examples
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below:
LinkedIn | Facebook | Twitter | Google+

Best Careers

Developer Tracks
SAN Developer
Linux Kernel Developer
Linux Driver Developer
Linux Network Developer

Live Training Photos
Mentoring
Software Productivity
GDB Assignment
Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel Programming. Our Founder has trained employees of almost all Top Companies in India such as VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft, Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium, ST-Micro, Samsung, LG-Soft, Wipro, TCS, HCL, IBM, Accenture, HSBC, Mphasis, Tata-Elxsi, Tata VSNL, Mindtree, Cognizant and Startups.

Best Trainings

SAN I - Technology
SAN II - Admin
Linux Fundamentals
Advanced C Training
Linux-C Debugging
System Programming
Network Programming
Linux Threads
Kernel Programming
Kernel Debugging
Linux Device Drivers

Best Reference Books

Computer Science Books
Algorithm & Programming Books
Electronics Engineering Books
Electrical Engineering Books
Chemical Engineering Books
Civil Engineering Books
Mechanical Engineering Books
Industrial Engineering Books
Instrumentation Engg Books
Metallurgical Engineering Books
All Stream Best Books

Questions and Answers

1000 C Questions & Answers
1000 C++ Questions & Answers
1000 C# Questions & Answers
1000 Java Questions & Answers
1000 Linux Questions & Answers
1000 Python Questions
1000 PHP Questions & Answers
1000 Hadoop Questions
Cloud Computing Questions
Computer Science Questions
All Stream Questions & Answers

India Internships

Computer Science Internships
Instrumentation Internships
Electronics Internships
Electrical Internships
Mechanical Internships
Industrial Internships
Systems Internships
Chemical Internships
Civil Internships
IT Internships
All Stream Internships

About Sanfoundry

About Us
Copyright
TOS & Privacy
Jobs
Bangalore Training
Online Training
SAN Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry