C++ Basics

C++ is a compiled language. To run a program, its source code has to be processed by a compiler, which creates object files, which connect the executable program by a linker. C++ program typically contain many source code files.

C++ Character Set

The character set is a combination of letters, digits, special symbols or white spaces, so learn to combine these letters to form words, which in turn are combined to form sentences and sentences are combined to form paragraphs.

There are 4 types of characters in C.


Lower case Letters: a,b,c,……….,y,z.
Upper Case Letters: A,B,C,………….,Y,Z.



3.Special Characters

~ tilde % percent sign | vertical bar @ at symbol
+ plus sign < less than & ampersand $ dollar sign
* asterisk \ back slash

4.White space Characters.

\b blank space \t horizontal tab \v vertical tab \r carriage return
\f form feed \n new line \\ Back slash ’ Single quote
\" Double quote \? Question mark \0 Null \a Alarm (Audible Note)

C++ Tokens

The smallest individual unit in a program is known as tokens.


These words have special meaning in the language, you cannot name a variable, function, template, type with any of these words. Each of these words already has a meaning and the compiler will stop any attempt to give them some other meaning.

For Example:- char, default, inline, switch, struct, etc.


A name given by the user to a unit of the program. An identifier may contain letters and numbers. The first letter must be a letter: the underscore _ counts as a letter. Upper case and lower case letters are different. All characters are important.


The Literals refers to constants as a fixed value that cannot be changed. This means literals are variables with a fixed value.

For example: int a = 42;


Punctuators are the special symbols used in program. This symbols are used to give proper form to statements, expressions.

For example: [] () {}, ; * = #


1. C++ provides various types of …………………… that includes keywords, identifiers, constants, strings and operators.

A. tokens
B. expressions
C. structures
D. None

View Answer

2. ………………….. are explicitly reserved identifiers and cannot be used as names for the program variables or other user defined program elements.

A. Keywords
B. Identifiers
C. Constants
D. Strings

View Answer


C++ Program to Add Two Numbers

#include <iostream>
using namespace std;
int main()
int first, second, sum;
cout << "Enter two integers: ";
cin >> first >> second;
// sum of two numbers in stored in variable sum
sum = first + second;
// Prints sum 
cout << first << " + " <<  second << " = " << sum;     
return 0;

Enter two integers: 4
4 + 5 = 9

Visit :


* You must be logged in to add comment.