logo
  • Home
  • Rank
  • Tests
  • 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
Practice 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

C++ Tests

C++ Tests

Best Reference Books

C++ Books
« Prev Page
Next Page »

C++ Programming Questions and Answers – Character Types

Posted on November 13, 2012 by Manish
This section on online C++ test focuses on “Character Types”. One shall practice these test questions 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 online C++ test questions come with detailed explanation of the answers which helps in better understanding of C++ concepts.

Here is a listing of online C++ test questions on “Character Types” along with answers, explanations and/or solutions:

1. How many characters are specified in the ASCII scheme?
a) 64
b) 128
c) 256
d) none of the mentioned
View Answer

Answer: b
Explanation: There are 128 characters defined in the C++ ASCII list.
advertisement

2. Select the right option.
Given the variables p, q are of char type and r, s, t are of int type
1. t = (r * s) / (r + s);
2. t = (p * q) / (r + s);
a) 1 is true but 2 is false
b) 1 is false and 2 is true
c) both 1 and 2 are true
d) both 1 and 2 are false
View Answer

Answer: c
Explanation: Every character constant has an integer value. Also char belongs to the integral type hence arithmetic and logical operations can be performed on them.

3. Which of the following belongs to the set of character types?
a) char
b) wchar_t
c) only a
d) both wchar_t and char
View Answer

Answer: d
Explanation: wchar_t and char is used to represent wide character and character.

4. What will be the output of this program?

  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         char c = 74;
  6.         cout << c;
  7.         return 0;
  8.     }

a) A
b) N
c) J
d) I
View Answer

Answer: c
Explanation: The literal value for 74 is J. So it will be printing J.
advertisement

5. How do we represent a wide character of the form wchar_t?
a) L’a’
b) l’a’
c) L[a].
d) la
View Answer

Answer: a
Explanation: A wide character is always indicated by immediately preceding the character literal by an L.

6. What is the output of this program?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char a = '\012';
  5.  
  6.         printf("%d", a);
  7.         return 0;
  8.     }

a) Compiler error
b) 12
c) 10
d) Empty
View Answer

Answer: c
Explanation: The value ‘\012’ means the character with value 12 in octal, which is decimal 10.
advertisement

7. In C++, what is the sign of character data type by default?
a) Signed
b) Unsigned
c) Implementation dependent
d) None of the mentioned
View Answer

Answer: c
Explanation: The standard does not specify if plain char is signed or unsigned. There are three distinct character types according to the standard: char, signed char and unsigned char.

8. Is the size of character literals different in C and C++?
a) Implementation defined
b) Can’t say
c) Yes, they are different
d) No, they are not different
View Answer

Answer: c
Explanation: In C++, sizeof(‘a’) == sizeof(char) == 1. In C however, sizeof(‘a’) == sizeof(int).

9. Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return?
a) 4
b) 1
c) Implementation dependent
d) Machine dependent
View Answer

Answer: b
Explanation: The standard does NOT require a char to be 8-bits, but does require that sizeof(char) return 1.

10. What constant defined in <climits> header returns the number of bits in a char?
a) CHAR_SIZE
b) SIZE_CHAR
c) BIT_CHAR
d) CHAR_BIT
View Answer

Answer: d
Explanation: CHAR_BIT is a macro constant defined in <climits> header file which expresses number of bits in a character object in bytes.

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

C++ Practice Resources
C++ Mock Tests & Certification Test | 1000 C++ MCQs | 1000 C++ Algorithms | Best C++ Books
« Prev Page - C++ Programming Questions and Answers – Booleans
» Next Page - C++ Programming Questions and Answers – Integer Types

« C++ Programming Questions and Answers – Booleans
C++ Programming Questions and Answers – Integer Types »
advertisement

Deep Dive @ Sanfoundry:

  1. C# Programming Examples on Conversions
  2. Java Programming Examples on File Handling
  3. C Questions and Answers
  4. Ruby Programming Questions and Answers
  5. C# Questions and Answers
  6. C Programming Examples on Strings
  7. Java Programming Examples on String Handling
  8. Programming Questions and Answers
  9. Object Oriented Programming Questions and Answers
  10. R Programming Questions and Answers
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
Terms
Privacy Policy
Jobs
Bangalore Training
Online Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry. All Rights Reserved.