Getting Started With C++ - 104832
Getting Started With C++ - 104832
Getting Started With C++ - 104832
Conceptual Question/Answers
Introduction
Tokens
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
Literals (Constants)
1. What is use of literals (Constants) in C++? Name the literals (Constants) allowed by C++.
» They are used to express specific values within the program.
C++ allows integer-constant, floating-constant, character-constant, string-literal and Bool literal.
2. What do you mean by integer constants?
» Integer constants are the whole numbers without any fractional part i.e., a constant having at least
one digit, +ve or -ve, without any decimal point.
3. Exemplify the different types of C++ integer constants.
» i) Decimal (base 10) : These are the integer constants that begin with a non-zero digit. e.g. 12 etc
ii) Octal (base 8) : These are the integer constants that begins with a zero. e.g. the decimal 12 will
be written as 010 in octal
iii) Hexadecimal (base 16) : These are the integer constants that begins with 0x or 0X. e.g. the
decimal 12 will be written as 0XC in hexadecimal.
4. What is a floating constant?
» A floating constants or a real constant is a number having fractional parts. e.g. -2.02, 0.5E01 etc.
5. Exemplify the different form of expressing a floating constant in C++.
» i) In fractional form, a real constant must have at least one digit before and after a decimal point.
It may be signed or unsigned. E.g. 17.215 etc.
ii) In exponential form, a real constant consists of two parts: mantissa, must be either an integer
or a proper real constant, followed by a letter 'E' or 'e' and, the exponent. e.g. 0.17215E02.
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
1. What do you mean by comments? What are its type supported by C++?
» Comments are the short explanations, notes or descriptions used by the programmers within a
program to enhance readability or understand ability of the program. C++ compiler ignores such
comments.
C++ supports two types of comments:
i) Single line comment: It starts with a pair of slash sign (//). The C++ compiler ignores everything
following the sign // in that line. E.g. //This is a single line comment
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
ii) Multi-line comment: This is also known as block comment. It includes more than one line
between /* and */ characters. The compiler ignores the statements between these characters.
E.g.,
/* This is a multi-line comment,
where line can flow below */
2. Which essential portion or condition, every C++ program must fulfil?
» Every C++ program must contain one and only one main () function, termed as driver function.
3. What is the significance of the main () function in C++?
» Every C++ program must contain the main() function, since
In C++, the execution of the program starts and ends at main() i.e. only the main() function is
executed.
It is the driver function of the program i.e., if not present, no execution takes place.
4. What do you mean by pre-processor directive in C++? What is its significance?
» The statement starting with an '#'(hash/pound) symbol is a pre-processor directive in C++.
It give instructions to the compiler to process the information defined before the start of actual
compilation.
5. What do you mean by include directive in C++? What is its significance?
» The include directive is the include statement, followed after the pre-processor directive #, i.e.
#include.
It causes the pre-processor to add the contents of the corresponding header file followed by the
include directive to the program where it is written.
6. Write two advantage of #include (include compiler) directive?
» It lets us to include all the desired header files in C++ program that enables us to work with all
declarations or definitions or macros inside the included header file(s).
It supports modularity i.e., decomposing a big program in terms of header files which can be later
included through this directive.
7. What is a header file? In C++, how many types of header files are there?
» Header files are C++ standard library files having an extension of .h to its name, containing the C++
functions declaration and macros definitions that are to be shared between several source files.
There are two types of header file, the files that comes with C++ compiler and the files that the
programmer writes.
8. Difference between #include<filename.h> and #include"filename.h".
» The statement #include<filename.h> describes that the specific header file is in the C++ standard
library directory that comes along with the C++ package, while, the statement #include "filename.h"
describes that the header file is user-defined present in the same directory where the source code is
but not in the standard library directory.
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
C++ Compilation
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT