You are on page 1of 31

C++

OBJECTIVE

Introduction of the features of C++.

SCOPE
C++ introduction

Managing Simple output operations

Understanding Menu

Data

Symbolic Constants

Reference Variable

Type cast operator

Scope Resolution operator

Programming constructs

Input Operation

Simple C++ program

(a) Creating a class & an object

(b) Accessing member functions from driver program.

Chapter-1/1
C++

C++ INTRODUCTION

WHAT IS C++

C++ was developed by Bjarne Stroustrup, of Bell Labs in early 1980s.

C++ is derived primarily from C & Simula 67.

C++ retains all of C’s strengths like :

(a) C’s power & flexibility in dealing with the hardware / software interface.

(b) Its low-level system programming

(c) Its efficiency, economy, and powerful expressions.

C++ supports object-oriented programming (OOP).

C++ programs are easily maintainable & expandable.

C++ versus C

Similarities

Case sensitive

Statements end with a semi-colon.

Every program is a collection of functions.

The program execution begins with the function main( ).

The explicit type conversion is allowed.

All variables need to be declared before using them.

Local & global variables can have same names. The program uses the value
of local variable.

Chapter-1/2
C++

Difference

C++ C
File name have .cpp extension File name have .c extension
Identifier can have any number of C compiler identifies only first 32
characters. characters of an identifier name.
Strongly typed language. It checks for Function prototypes may or may not be
the number & type of formal arguments included.
as well as the return data type. This
check is performed between the function
call & function definition.
Default values for the parameters in the This facility is not available in C.
function’s prototype is possible.
The function main() returns an integer The function main() does not return
type value any value
The user-defined data type class is also Only struct & union , data types are
available alongwith struct & union. available
The declarations of the variables can be The declaration of the variables must be
placed close to the statements that use at the beginning of the function.
the variables
Global variable can be accessed with the Global variable cannot be accessed if
scope resolution operator (::), in case the the program has the local variable with
program has the local variable with the the same name.
same name.
C++ compiler interprets the & operator C compiler interprets the & operator as
according to the context of the address.
statement, either as address or as
reference.

Chapter-1/3
C++

MANAGING SIMPLE OUTPUT OPERATIONS

PROGRAM FEATURES

Every C++ program starts with main(), which returns an integer type value.

main() declaration :

main() { void main() {


......... ...........
......... ...........
......... OR ...........
return (0); }
}

C++ has its own set of I/O library syntax, which are defined in a header file
called ‘iostream.h’. This header file needs to be included before main().

SENDING A CHARACTER STRING TO SCREEN

OUTPUT OPERATOR : cout

INSERTION OPERATOR : <<

EXAMPLE

PROBLEM : To print the statement “C++ IS A SUPERSET OF C”

PROGRAM STATEMENT: cout << “C++ IS A SUPERSET OF C” ;

OUTPUT: C++ IS A SUPERSET OF C

The insertion operator can be cascaded.

EXAMPLE

PROBLEM : To print the statements “C++ IS A SUPERSET OF C” and “IT


SUPPORTS OBJECT-ORIENTED PROGRAMMING” on different lines.

PROGRAM STATEMENT:

cout << “C++ IS A SUPERSET OF C” << ‘\n’ << “IT SUPPORTS OBJECT-ORIENTED PROGRAMMING”;

Chapter-1/4
C++

OUTPUT: C++ IS A SUPERSET OF C


IT SUPPORTS OBJECT-ORIENTED PROGRAMMING

COMMENT ENTRIES

Comments increase the readability of the program code.

In C++, comments can be given in two ways :

Single line comments /* comment */


or
// comment

Multiple line comments /*


comment
*/

Chapter-1/5
C++

UNDERSTANDING MENU

WRITING A PROGRAM

To open a new program file - New option of File sub-menu.

Various type of files can be opened. To start with choose Text file.

Write the program in the workspace provided.

To save the file - Save option of File sub-menu. The extension of .cpp is
given by the Developer Studio ( an interface between the user & Visual C++ ).

To close the file - Close option of File sub-menu.

To open the file - Open option of File sub-menu.

To compile a program - Compile option of Build sub-menu.

To link a program - Build option of Build sub-menu. Creates an .exe file.

To execute the program - Execute option of Build sub-menu.

CLASSROOM EXERCISE

Why the header files are included in C++ programs?

Chapter-1/6
C++

DATA

TOKENS

It is the smallest unit of a program.

Types Of Tokens

IDENTIFIERS

KEYWORDS

DATA TYPES

IDENTIFIERS

They refer to the names used to represent variables, constants, functions


in a program.

Consists of letters, numbers or underscore.

Can have any number of characters.

Cannot start with a decimal number.

C++ identifies uppercase & lowercase alphabets as separate characters.

Use of two sequential underscores (__) is reserved for C++


implementation & standard libraries.

Variable identifier usually have first character as ‘l’ or ‘g’ specifying


local or global variable respectively. Second character represents the data
type of the variable followed by a meaningful name. By default the first
character is assumed to be local.

EXAMPLE

Valid Identifiers
liGrandTotal indicates local integer variable for storing grand total
gfFreuency indicates global float variable for storing frequency
sNameOfEmp indicates local string variable [ character array ] for storing name of
employees
piRangeOfNum indicates integer pointer (local pointer)
CalculateSum indicates a function to calculate sum

Chapter-1/7
C++

CLASSROOM EXERCISE

Which of the following identifiers are illegal :


(a) ^SoundTrack
(b) iMax@
(c) 1stIdentifier
(d) s1stName

KEYWORDS

They are the predefined identifiers that have special meanings to the
C/C++ compiler.

Cannot be used as names for the program variables or other user-defined


program elements.

C++ Keywords
auto do if short
break double inline sizeof
case else int static
char enum long struct
class extern new switch
const float operator typedef
continue for private union
default friend protected virtual
delete goto public void
return while

DATA TYPES

Data types in C++ can be divided into three groups as follows:

(a) Basic data type

(b) User-defined type

(c) Derived type

Chapter-1/8
C++

DECLARING & INITIALIZING VARIABLES

Variables can be declared at any place in the program.

Dynamic initializing of variables is also allowed.

Dynamic initialization means initializing by an expression instead of a


constant. This type of initialization is done at run-time.

Syntax for declaring a variable -


data type variable name;

Syntax for initializing a variable -


data type variable name = initial value;

EXAMPLE

float fSum ; // declaring a variable

float fSum = 50.5 ; // initializing a variable

float fAverage = fSum / 5 ; // Dynamic initialization of variable

Chapter-1/9
C++

Basic data type

Type Storage Range of Values


char 1 byte -128 to 127
int 2 bytes -32,768 to 32,767
short 2 bytes -
32,768 to 32,767
long 4 bytes -2,147,483,648 to
2,147,483,647
unsigned char 1 byte 0 to 255
unsigned int 2 bytes 0 to 65,535
unsigned short 2 bytes 0 to 65,535
unsigned long 4 bytes 0 to 4,294,967,295
float 4 bytes 3.4E-38 to 3.4E+38
double 8 bytes 1.7E-308 to
1.7E+308
long double 10 bytes 1.1E-4932 to
1.1E+4932

void Basic Data Type

Used to specify the return type of function when it is not


returning any value.

Indicates an empty argument list to a function.

Used as generic pointer that can be assigned a pointer value of


any basic data type.

EXAMPLE

Function not returning any value can be defined as

void CalculateSum(int iNumber);

Function with no parameters can be defined as

float CalculateAverage(void);

Generic pointer can be declared as

void *pvGenericPointer;

C++ uses void data type. This data type is available in ANSI C.

Chapter-1/10
C++

CLASSROOM EXERCISE

Let int *piIntPointer; // An integer pointer


void *pvVoidPointer; // A void pointer

Which of the following assignments are illegal & why ?


1. /* Assigning the value of void pointer to an integer pointer */
piIntPointer = pvVoidPointer;
2. /* Assigning the value of integer pointer to a void pointer */
pvVoidPointer = piIntPointer;

User-Defined Data Type

struct & union are user-defined data types . These data types are
same in C as well as in C++.

enum user-defined data types is available in C & C++.

class is a user-defined data type available only in C++.

enum Data Types

Used for assigning names to the numbers.

The numbers are assigned in increasing from 0.

EXAMPLE

enum eFurniture {Table, Chair, SofaSet};

Note - Table will have value 0 , Chair will have 1, and so on.

enum eMarks {Zero, One, Two, JustPass = 49, Pass, Full = 100};

Note - Zero will have value 0, One will have 1, JustPass will have 49
instead of 3, Pass will have 50 & Full will have 100.

Variable declaration of data type eMarks

eMarks eNumberObtained;

If eNumberObtained = JustPass then instead of writing 49 the


variable eNumberObtained can be used.

Chapter-1/11
C++

C++ allows declaration of anonymous enums.

EXAMPLE

enum {Yes, No};

Note - Yes has the value 0 & No has the value 1.

Derived Data Type

The data types formed from the basic data types are called derived
data types.

Arrays, Functions & Pointers are derived data types available in both
C & C++.

C++ also supports constant pointer & pointer to constants.

Constant pointer where pointer location cannot be modified.

Pointer to constants where content of pointer location cannot be


modified.

EXAMPLE

int iMarks;
int * const piMarksObtained = & iMarks ; // constant pointer

/* Location of pointer piMarksObtained cannot be modified. */

const int iMarks;


int const * piMarksObtained = & iMarks ; // pointer to constant

/* Location of pointer piMarksObtained can be changed, but the content


of the location cannot be modified. */

Chapter-1/12
C++

CLASSROOM EXERCISE

Let int const iNumber = 10;


char const cAlphabet = ‘n’;
int iMark = 20;
char cStatus = ‘y’;

Identify which of the following declarations / assignments are illegal & why?
(a) int * const piIntPointer = & iNumber;
(b) int * const piIntPointer = & iMark;
(c) char * const pcCharPointer;
(d) const char * pcCharPointer = & cAlphabet;
(e) const char * pcCharPointer = & cStatus;

Chapter-1/13
C++

SYMBOLIC CONSTANT

Used to give a name to any constant value so as to make it more


explanatory.

In order to change the value of a constant , the change needs to be made at


only one location instead of throughout the program.

These constants can be declared with

(a) #define

(b) const keyword

(c) enum keyword

EXAMPLE

#define iMax 20
or
const int iMax = 20;
or
enum { iMax = 20 };

/* This indicates that in the program instead of using 20 the word iMax can be used.
iMax is a constant variable */

Chapter-1/14
C++

REFERENCE VARIABLE

Used to give an alternate name to previously declared variable.

Reference variable and the original variable share the same memory location.

Its name is preceded with the symbol &.

Used to pass parameters between functions as it removes copying the variables


back and forth.

Syntax for declaring reference variable

data type & reference variable name = variable name ;

EXAMPLE 1

/* cAlternate and cAlphabet share the same memory location. */

char cAlphabet = ‘v’;


char & cAlternate = cAlphabet;

EXAMPLE 2

PROBLEM- Calculate the average of 5 numbers using a function call. The average needs to
be calculated with sum as 50.5 (given in the main) & with sum as 10
(modified in the function).

/* Passing parameter by reference


The parameter Average is passed by reference whereas parameter Sum is passed by
value. The changes are reflected only if the parameters are passed by reference. */

/* Function to calculate average where fSump & fAveragep are the parameters. fSump
have the value of fSum & fAveragep have the value of fAverage */

void CalculateAverage ( float fSump, float & fAveragep) {

fSump = 10; // Changing the value of Sum


fAveragep = fSump / 5 ; // Calculating Average

/* Printing the Average & Sum */

cout << “ Inside the called function ” << ‘\n’;


cout << “ Average =” << fAveragep << ‘\n’;
cout << “Sum = ” << fSump << ‘\n’;
}

Chapter-1/15
C++

/* Main Function */

void main ( ) {

float fSum = 50.5 ; // Declaration & Initialization of variable to hold Sum


/* Declaration & Initialization of variable used to calculate Average */
float fAverage = 0;

/* Calling Function CalculateAverage, to calculate average */

CalculateAverage ( fSum, fAverage);

/* Printing the Average & Sum */

cout << “ Inside main ” << ‘\n’;


cout << “ Average =” << fAverage << ‘\n’;
cout << “Sum = ” << fSum;
}

OUTPUT - Inside the called function


Average = 5.05
Sum = 10
Inside main
Average = 10.1
Sum = 50.5

CLASSROOM EXERCISE

1. Find the output of the following program -

void CalculateAverage ( float *fSump, float & fAveragep) {


*fSump = 10;
fAveragep = *fSump / 5 ;
cout << "Inside the called function" << '\n';
cout << "Average =" << fAveragep << '\n';
cout << "Sum = " << *fSump << '\n';
}
void main( ) {
float fSum = 50.5;
float fAverage = 0;
CalculateAverage ( &fSum, fAverage);
cout << "Inside main " << '\n';
cout << "Average =" << fAverage << '\n';
cout << "Sum = " << fSum;
}

2. Differentiate between the pointer and the reference variable ?

Chapter-1/16
C++

TYPE CAST OPERATOR

Used to explicitly convert the data type of a variable or a constant.

Need arises in case of mixed-mode operations using different data types.

Syntax for type conversion -


data type = (type cast operator) expression ;

EXAMPLE

float lfAverage; // Local variable to hold average


int liSum = 12; // Local variable to store sum
/* Local variable to store the number of elements whose average is calculated */
int liNumber = 5;

lfAverage = (float) liSum / liNumber ; // Type conversion statement

CLASSROOM EXERCISE

Find the output of the following program -

void main( ) {
int liSum = 12;
int liNumber = 5;
float lfAverage;

/* Type casting the result of the expression */


lfAverage = float(liSum / liNumber);

/* Printing Average */
cout << "Average =" << lfAverage << '\n';

/* Type casting the variable liSum */


lfAverage = (float) liSum / liNumber;

/* Printing Average */
cout << "Average =" << l fAverage << '\n';

/* Type casting variable liNumber */


lfAverage = liSum / (float) liNumber;

/* Printing Average */
cout << "Average =" << lfAverage << '\n';

/* Calculating Average without type casting */


lfAverage = liSum / liNumber;
cout << "Average =" << lfAverage << '\n'; }

Chapter-1/17
C++

SCOPE RESOLUTION OPERATOR

Used to access the global variable if the local variable has the same name as
that of the global variable.

Used to remove the conflict between a variable with different scopes.

Major application is in classes to identify the member function’s class.

Represented by the symbol ::

Syntax for accessing the global variable -


:: variable name

EXAMPLE 1

PROBLEM- Display the value of local & global variables having same name.

PROGRAM- #include <iostream.h>

/* iNumber is a variable to store the value of a number. This variable is


used both as a local variable and global variable */

int iNumber = 10; // Global variable

void main ( ) {
int iNumber = 7; // Local variable

/* Displaying variables */

cout << "Number = " << iNumber << '\n'; // Displaying local variable
cout << "Number = " << :: iNumber << '\n'; // Displaying global variable
}

OUTPUT - Number = 7
Number = 10

EXAMPLE 2

PROBLEM- Display the value of local & global variables having same name. Multiple
local variables are declared in different blocks.

PROGRAM- #include <iostream.h>

int iNumber = 10; // Global variable

Chapter-1/18
C++

void main ( ) {

int iNumber = 5; // Local variable of outer block

/* Displaying local variable of outer block */


cout << "Local Number = " << iNumber << ‘\n’;

/* Displaying global variable */


cout << "Global Number = " << ::iNumber << '\n';

/* Inner block */
{
int iNumber = 7; // Local variable of inner block

/* Displaying local variable of inner block */


cout << "Local Number = " << iNumber << ‘\n’;

/* Displaying global variable */


cout << "Global Number = " << ::iNumber << ‘\n’;
}
}

OUTPUT - Local Number = 5


Global Number = 10
Local Number = 7
Global Number = 10

HOME ASSIGNMENT

Find the output of the following program -

#include <iostream.h>

int iNumber = 10;

void DisplayNumber ( ) {
int iNumber = 5;
cout << "Number = " << iNumber << '\n';
cout << "Number = " << :: iNumber << '\n';
}
void main ( ) {
int iNumber = 7;
DisplayNumber ( );
cout << "Number = " << iNumber << '\n';
cout << "Number = " << :: iNumber << '\n';
}

Chapter-1/19
C++

PROGRAMMING CONSTRUCTS

DECISION MAKING CONSTRUCT

(a) if Statement

Used to conditionally execute the code.

Syntax -
if (expression) {
true actions ;
}
else {
false actions ;
}
Note: The result of the expression should be either TRUE or FALSE.
else is optional.
Nested ifs are possible.
if-else-if is also possible.

(b) switch Statement

Used to avoid if-else-if statements.

Syntax -
switch (expression) {
case constant1:
statements to be performed;
break;
case constant2:
statements to be performed;
break;
default:
statements to be performed;
}

Note - Number of case can vary depending upon the instances //alternatives
possible.
break statement skips the remaining checks.

Chapter-1/20
C++

EXAMPLE

PROBLEM - Write the code statements to call the functions DisplayAverage,


CalculateAverage or InputNumbers based on the menu option selected by the
user. DisplayAverage function is called if menu option is 1, function
CalculateAverage is executed if menu option is 2, and InputNumbers if
option is 3. In case of any other option error message is displayed.

PROGRAM-
/* iOption is an integer variable used to accept the choice from the user based
on the menu */

if (iOption == 1)
DisplayAverage ( );
else if (iOption == 2)
CalculateAverage ( );
else if (iOption == 3)
InputNumbers ( );
else
cout << “ERROR HAS OCCURRED” ;

HOME ASSIGNMENT

Write the solution for the above discussed problem with switch
statement ?

LOOP CONSTRUCT

(a) for Statement

Used to perform repetition of steps for a determined number of times.

Syntax -
for (initialization expression ; test expression ; incrementation expression ) {
action steps ;
}

EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers

Chapter-1/21
C++

PROGRAM-#include <iostream.h>

void main( ) {

/* Variable declaration & initialization */


/* A variable to count the number of times a loop is executed. */
int liCounter ;
int liSum = 0 ; // A variable to store the calculated sum.

/* Loop construct to calculate sum */


for (liCounter = 1; liCounter <= 10 ; liCounter ++) {
liSum = liSum + liCounter ;
}

/* Displaying the value of sum */


cout << “Sum is” << liSum;
}

OUTPUT- Sum is 55

(b) while Statement

Used like for loop.

Can also be used in case there is no incremental variable.

Syntax -
while ( test expression ) {
action steps ;
}

EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers

PROGRAM -#include <iostream.h>

void main( ) {

/* Variable declaration & initialization */


/* A variable to count the number of times a loop is executed. */
int liCounter ;
int liSum = 0 ; // A variable to store the calculated sum.

Chapter-1/22
C++

/* Initializing liCounter to 1 */
liCounter = 1;

/* Loop construct . Loop is performed 10 times */


while (liCounter <= 10 ) {
liSum = liSum + liCounter ;
liCounter ++;
}

/* Displaying the value of sum */


cout << “Sum is” << liSum;
}

OUTPUT- Sum is 55

(c) do - while Statement

Used when the loop needs to be executed atleast once.

The condition is checked only at the end.

Syntax -
do {
action steps ;
} while ( test expression );

EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers.

PROGRAM-#include <iostream.h>

void main( ) {

/* Variable declaration & initialization */


/* A variable to count the number of times a loop is executed. */
int liCounter ;
int liSum = 0 ; // A variable to store the calculated sum.

/* Initializing liCounter to 1 */
liCounter = 1;

/* Loop construct . Loop is performed 10 times */


do {
liSum = liSum + liCounter ;
liCounter ++;
} while (liCounter <= 10 )

Chapter-1/23
C++

/* Displaying the value of sum */


cout << “Sum is” << liSum;
}

OUTPUT- Sum is 55

HOME ASSIGNMENT

Write the program to print the following design -

0
1 **
2 ****
3 ******
4 ********

Chapter-1/24
C++

INPUT OPERATIONS

RECEIVING THE VALUE OF A VARIABLE FROM THE SCREEN

INPUT OPERATOR : cin

EXTRACTION OPERATOR : >>

EXAMPLE

int iNumber;
cin >> iNumber; // Accepting the value in the variable iNumber

The extraction operator can be cascaded.

EXAMPLE

float fMarks1, fMarks2;

/* Accepting the values in the two variables fMarks1 & fMarks2 */


cin >> fMarks1 >> fMarks2 ;

/* The input can be given as together with a space between the two values 23.4 45.0
or on separate lines like
23.4
45.0
*/

Chapter-1/25
C++

SIMPLE C++ PROGRAM

CREATING A CLASS

Class

User-defined data type.

Used to encapsulate data (data hiding).

Syntax for declaring a class -


class class-name {
attributes of the class
behavior of the class
};
EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers

PROGRAM- /* Declaring the class Number */


class Number {
};

Data Members

These are the attributes / state of the class.

Represented in the form of variables.

Can have access as public, private or protected depending upon its


usage.

Declared under appropriate access specifier.

Access specifier is followed by a colon (:) and the declarations of the


data members.

Cannot be initialized with declaration.

EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers

Chapter-1/26
C++

PROGRAM- /* Declaring the data members */

private :

/* A variable to count the number of times a loop is executed. */


int liCounter ;
int liSum = 0 ; // A variable to store the calculated sum.

Member Functions

These are the behavior state of the class.

Represented by the functions which perform operations on data members.

Can have access as public, private or protected depending upon its usage.

Declared under appropriate access specifier.

Syntax for declaring a member function -


return-type member-function-name(parameters)

Defined after the class declaration.

Syntax for defining a member function -


return-type class-name :: member-function-name(parameters) {
function code;
}

EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers

SOLUTION- Identify the functions required for the class Number declared earlier.
Data members ( liCounter , liSum) of this class are also declared.

Functions can be
(a) To initialize the data members (InitialDataMembers)
(b) To calculate sum (CalculateSum)
(c) To display sum (DisplaySum)

PROGRAM- /* Function declaration */


public :
void InitialDataMembers( );
void CalculateSum ( );
void DisplaySum ( );

Chapter-1/27
C++

/* Function definition */

void Number :: InitialDataMembers( ) {


liCounter = 1;
liSum = 0;
}

void Number ::CalculateSum ( ) {


do {
liSum = liSum + liCounter ;
liCounter ++;
} while (liCounter <= 10 );
}

void Number ::DisplaySum ( ) {


cout << "Sum is"<< liSum;
}

OUTPUT - Sum is 55

CREATING AN OBJECT

An object is an instance of the class.

Public data members & member functions are accessed through an object.

Syntax for creating an object -


class-name object-name;

EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers.

PROGRAM- /* Declaring an object oNumber1 */


Number oNumber1;

ACCESSING MEMBER FUNCTIONS

Driver program plays a key role in controlling the flow of the software.

main ( ) is usually the driver program.

Syntax to access the member functions -

Chapter-1/28
C++

object-name.member-function-name(parameters)

EXAMPLE

PROBLEM - Calculate the sum of first 10 integer numbers.

PROGRAM- /* Driver program */


void main ( ) {
Number oNumber1;
oNumber1.InitialDataMembers( );
oNumber1.CalculateSum ( );
oNumber1.DisplaySum ( );
}

CLASSROOM EXERCISE

Write a program to calculate the average of 10 numbers given by the user ?

HOME ASSIGNMENT

1. Write a program to display the Fibonnaci series 0,1,1,2,3,5,8 ?

2. Write a program to print the interest on the basis of principle, time


& rate given by the user ?

Note : Use C++ class to implement the above programs

Chapter-1/29
C++

SUMMARY

Key points covered in this session

C++ is the enhancement of C.

Output operations can be performed with printf as well as cout.

cout takes care of the data type itself unlike printf.

enum keyword can be used to declare anonymous symbolic constants.

Passing parameters with reference gives the same facility as with pointers. The
added advantage is reference variable doesn’t require new memory location.

Dynamic initialization is allowed in C++ & not in C.

Type cast operator & programming constructs work similar in C as well as


C++.

Global variable can be accessed with scope resolution operator.

scanf , gets, getch & cin provides input operations.

Class facilitates the data hiding property of Object-Oriented Programming.

Member functions can be accessed only through object.

Chapter-1/30
C++

LAB EXERCISE

1. Write a program to encrypt the character string entered by the user. The string
cannot have more than 10 characters. The encrypted string should have each
character replaced by the one that occurs after 2 places in the alphabet. For
example - APPLE is encrypted as CRRNG.

2. Write a program to reverse a number.

Note : Use C++ class to implement the above programs

Chapter-1/31

You might also like