0% found this document useful (0 votes)
17 views

anurag

Uploaded by

Raghav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

anurag

Uploaded by

Raghav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

A

Training Report
On

CUSTOMER PAYEMNT AND


BILLING SYSTEN(C++)

Submitted for Partial Fulfillment of the Award of


Bachelor of Technology (B.Tech) in CSE Deptt.
Kurukshetra University Kurukshetra

Submitted By:

RAGHAV
DUGGAL
1222210

Submitted to:

Department of Computer Science &


Engineering, JMIT RADAUR
Affiliated to Kurukshetra University, Kurukshetra
DECLARATION
I hereby certify that the work which is being presented in the Training Report entitled, “” by me,
RAGHAV DUGGAL(Roll No.1222210) in partial fulfillment of the requirements for the award of degree of
Bachelor of Technology in Computer Science & Engineering

at JMIT Radaur (Affiliated to Kurukshetra University Kurukshetra) is an authentic record of my own


work carried out under the supervision of Dr./Prof./Er. Manjit Singh.

(Raghav Duggal )
ACKNOWLEDGEMENT

The writing of this training report has been assisted by the generous help of many people. I feel
that I was very fortunate to receive assistance from them. I wish to express my sincere
appreciation to them.

First and foremost, I am indebted to my principal supervisor, Er./Mr. Manjit Singh (Director)
of Oops InfoSolutions Pvt ltd. who has been very supportive at every stage of my preparations.
I wish to express my utmost gratitude to him for his invaluable advice and patience in reading,
correcting and commenting on the drafts of the report and, more importantly, for his generosity
which I have received throughout my training program.

I would like to acknowledge and extended my heartfelt gratitude to Dr. Gaurav Sharma, Head
of Department who provided me the golden opportunity to undergo and complete this training
program.

I wish to express my thanks to Er. Rajiv Bansal who also helped me in conducting this study
and encouraged me throughout this journey.

Finally, I am particularly indebted to my dearest parents/guardians as without their generous


assistance and love; this dissertation could never have been completed.

PRIYA MEHTA
1222136

PREFACE

Objectives of the Training:

This curriculum based summer training program provided an understanding about building
application using C++.

Throughout the training program, I not only developed technical expertise but also cultivated critical
problem-solving skills, logical thinking, and the ability to design and implement solutions for real-
world challenges.

The journey of learning to program is a continuous process of growth and exploration. This training
program provided me with a strong foundation, and I had the opportunity to nurture and expand my
knowledge. I actively participated, asked questions, sought guidance, and experimented with the
concepts I learned. Embracing the challenges allowed me to emerge from this summer training as a
confident programmer, ready to take on exciting coding adventures.

Overall, this training program was an enriching experience. It was a journey of discovery and
learning as I explored the fascinating world of C++ programming and successfully built a cricket
game application that showcased my skills and creativity. I am grateful for the knowledge gained and
look forward to applying it to future projects.
TABLE OF CONTENTS

1. Declaration…………………………………………………….3

2. Acknowledgement…………………………………………4

3. Preface………………………………………….................5

4.Company Profile................................................6-8

CHAPTER 1
1. About C++……………………………………………………....10

2. C++ keywords………………………………………………….12

3. Operators………………………………………………………...15

4. Typecasting…………………………………………………….....19

5. Control Statements………………………………………......20

6. Loop Control Statements…………………………...........22

7. C++ Functions……………………………………………….......26

8. Class……………………………………………………………….......31

9. Object…………………………………………………………..........32

10. Scope Resolution Operator………………………...........34

11. Pointers……………………………………………………..........35

CHAPTER 2
12. Introduction to the Project………………………...36

13. Source Code……………………………………………….37

14. Output……………………………..............................47
COMPANY PROFILE
OOPS INFO SOLUTIONS PVT .LTD.

(Manjit Singh, Ex-Infosys employee,15 Year experience in IT, Java, J2EE, PHP, Android, Networking)
Oops Info Solutions was established in 2003. It’s foundation and purpose is to provide and construct programs for existing companies and
provide new and exciting updates to primitive bases technology.
Oops Info Solutions Pvt. Ltd. is a India-based IT service provider offering services for technology infrastructure, enterprise resource planning,
software application engineering and imparting Training. Oops was established on January 2003 and has consistently grown its client base.
Featured in Computer Times, IT India and Computer World, With India as the base for centralized Project Management, Oops has expanded
its representative office both in Chandigarh and Mohali in 2003. Oops also started operating software development center in the year 2004 and
2006. In 2011, Oops was nominated in “Spirit of Enterprise”, which advocates and promotes entrepreneurial spirit of Indians.
Oops is currently a registered member of Professional Training and Software Development. Oops is also ISO Certified Company. In 2013-14
Oops has also entered in Developing Mobile Apps.
It is currently working in Designing mobile apps and integrating apps with the Websites.

Goals of the Company


The goal of Oops is to be responsive to its users and provide them with software solution to assist them in being more efficient and productive
in their work. The company plans on continually improving software to help its clients take advantage new technology.

Board of Directors
The Group Management Board comprises the Vice Chairman & Managing Director, Presidents of the Business Sectors as well as heads of
certain key corporate functions. The Board provides strategic direction and enterprise leadership, facilitates synergistic and symbiotic
relationships and creates a shared vision and value-system, across the various Business Units and Companies that make up the OOPS group.
The membership of the Group Management Board is as follows:
Manjit Singh (Managing Director)
Gurpreet Kaur (Executive Director)

Overview of the Company


Oops specializes in systems, local and wide area networks, wireless solutions, internet-related technologies and network security. Being a one-
stop information technology systems provider, we meet all hardware, software, consulting and services requirements. From basic data cabling
or workstation configuration to complex data centers and enterprise-web solutions, you can find it all under Oops Info Solutions Pvt Ltd. With
our pool of competent and experienced Sun Microsoft,Novell, Unix, and Cisco certified engineers, we design, plan and deploy conventional or
cutting edge technology-based networks. As we treasure all business partnerships and opportunities, nothing is too small for us. In some
cases, Oops can also act as sub-contractors for extremely large framework deployment.

Strategic Technology Consulting Services (STCS)


With immerse changes in the technology industry, technology strategy is being tied even closer with overall business strategy as companies
leverage the latest advancements to keep ahead of the competitive curve. Oops group of experienced technology experts and IT architects can
assist in mapping business requirements with tomorrow’s technology.

System Integration Services (SIS)


All open systems must be integrated to be useful in an environment. Oops provides multi-platform systems services from architecture, design,
analysis, to integration. As our system engineers are competent in Windows, Unix, Linux, Novell, Sun/Solaris and even mini-computers or
mainframe environment, a seamless integration is ensured.
Network Security Audit and Solutions Services (NSAS)
Don’t compromise your security.Oops provides a comprehensive analysis of the enterprise environment identifies and corrects vulnerabilities,
and helps enforce security policy. We enable organizations to monitor their networks and systems round the clock for attacks and misuse.

LAN, WAN and Wireless Network Services (LWWS)


With a pool of technology savvy engineers, Oops design, plan and deploy various types of network to meet an organization’s needs based on
the latest technology without compromising its budget. In addition, we assist in network analysis, performance tuning and management. From
the earliest planning stages to meeting daily operation requirements, it’s our job to make your job easier. The People The software application
engineering team architects, designs, builds, and deploys technology based business solutions.
Be it open source, web-based or client server application development, experience has refined oops knowledge in all areas. oops takes
advantage of developments using both open source technology and Microsoft development tools to help clients cut costs and yet obtain quality
output. The Capabilities Organizations can get expert and skilled services as IT consultants are fully trained on the latest technologies.
Problems concerning indispensability and suitability of IT staff are addressed. Core business units receive professional guidance and support
leading to reduction of bottlenecks and costly system downtime.
Technology management will be left to the experienced hands of IT professionals

C++ PROGRAMMING TRAINING IN CHANDIGARH /


MOHALI

Developments in software technology have been always dynamic. New languages like C++ Programming and new techniques like oops
concepts are announced everyday; as a result, engineers and software industries need to track the new changes to continue the development.
However, there are many programming languages, but the Object-Oriented Programming Language is the most preferred one in the software
industry. It offers the user a new approach to build the real-time application along with a way to cope the complexity of other programs. Among
the oops languages available, C++ Programming is the most widely used one. Moreover, it is the most versatile language used for handling
very large programs and suitable for programming task including development of compilers, editors and any real-time complications The ability
to map the real life problems, makes C++ programming the most popular and the most important course for the software industry. It would be
indeed to say that there are many colleges and institutes, which give training of this course to students. Among the institutes available, Oops
Info Solutions Chandigarh is one among them offering this course for a term of 2 months. Oops Info Solutions has extensive experience
trainers to guide the students for real-time projects. Apart from the course, it also assures the enrolled students for 100% placement
opportunity. Most of the times, the seats are booked in advance.
TRAINING SCHEDULE w.e.f. JULY 10, 2023

Time Contents
Duration
INTRODUCTORY In the very begining,I stepped up into the corporate world .,knowing the importance
WEEK of projects ,certifications courses and internship programs interacting with number of
people in domain.
(10JULY-16JULY)
Getting Started with C++: The training commenced with a solid foundation in C++,
one of the foundational programming languages that laid the groundwork for modern
WEEK-1 programming. I learned to set up my development environment, wrote my initial C++
(JULY 17-JULY programs, and gained familiarity with the language's basic syntax and concepts.
23)
Fundamentals of Object-Oriented Programming (OOP) Using C++: In this segment,
I learned the principles of Object-Oriented Programming (OOP) through the lens of
WEEK-2 C++. I created classes, objects, and implemented concepts such as encapsulation,
(JULY 24 – JULY 30)
inheritance, and polymorphism.

WEEK-3 Completed the 3rd module and had a firm grasp of all the concepts of
(JULY 31 – Object-Oriented Programming (OOP) Using C++.
AUGUST 6)
Diving into C++ Programming: Building upon my C++ foundation, I ventured into
WEEK-4 more advanced features and techniques within the language. Topics included
memory management, file handling, and advanced data structures. This phase of the
(AUGUST 7-
training enabled me to write efficient and maintainable C++ code
AUGUST 13)
WEEK-5 Building a Real World Customer PaymentSystem: The pinnacle of this training
program was the practical application of my newly acquired skills. I applied my C++
(AUGUST 14- knowledge to design and implement a billing and payment system from scratch. This
AUGUST 20)
real-world project encompassed user interactions,logics and the creation of an
engaging user experience.

WEEK-6 Completed the project and also gave the Final test. Received the certificate of
completion
(AUGUST 20-
AUGUST 25)

1.1 ABOUT C++

C++ is an object oriented programming language. It was developed by Bjarne Stroustrup in 1979 at Bell Laboratories in Murray
Hill, New Jersey. He initially called the new language "C with Classes." However, in 1983 the name was changed to C++.

C++ is a superset of C. Stroustrup built C++ on the foundation of C, including all of C’s features, attributes, and benefits. Most of
the features that Stroustrup added to C were designed to support object-oriented programming .These features comprise of
classes, inheritance, function overloading and operator overloading. C++ has many other new features as well, including an
improved approach to input/output (I/O) and a new way to write comments.

C++ is used for developing applications such as editors, databases, personal file systems, networking utilities, and
communication programs. Because C++ shares C’s efficiency, much high-performance systems software is constructed using
C++.

A Simple C++ Program


#include<iostream.h>

#include<conio.h>

int main()

cout<< “Simple C++ program without using

class”; return 0;

Lines beginning with a hash sign (#) are directives read and interpreted by what is known as the preprocessor. They are special
lines interpreted before the compilation of the program itself begins.

In this case, the directive #include , instructs the preprocessor to include a section of standard C++ code, known as header
iostream that allows to perform standard input and output operations, such as writing the output of this program to the
screen.

The function named main is a special function in all C++ programs; it is the function called when the program is run. The
execution of all C++ programs begins with the main function, regardless of where the function is actually located within the
code.

The open brace ({) indicates the beginning of main's function definition, and the closing brace (}) indicates its end.

The statement :

cout<< “Simple C++ program without using class”;

causes the string in quotation marks to be displayed on the screen. The identifier cout (pronounced as c out) denotes an
object. It points to the standard output device namely the console monitor. The operator << is called insertion operator. It
directs the string on its right to the object on its left.
The program ends with this statement:

return 0;

This causes zero to be returned to the calling process (which is usually the operating system). Returning zero indicates that the
program terminated normally. Abnormal program termination should be signaled by returning a nonzero value.

1.2 C++ KEYWORDS


When a language is defined, one has to design a set of instructions to be used for communicating with the computer to carry
out specific operations. The set of instructions which are used in programming, are called keywords. These are also known as
reserved words of the language. They have a specific meaning for the C++ compiler and should be used for giving specific
instructions to the computer.

These words cannot be used for any other purpose, such as naming a variable. C++ is a case sensitive language, and it requires
that all keywords be in lowercase . C++ keywords are :
1.3 Identifires
An identifier is a name assigned to a function, variable, or any other user-defined item. Identifiers can be from one to several
characters long.
Rules for naming identifiers

▪ Variable names can start with any letter of the alphabet or an underscore. Next comes a letter, a digit, or an underscore.

▪ Uppercase and lowercase are distinct.

▪ C++ keywords cannot be used as identifier.

C++ allows certain of the basic types to have modifiers preceding them. A modifier alters the meaning of the base type so that
it more precisely fits the needs of various situations. The data type modifiers are: signed, unsigned, long and short.

1.4 Data types

This figure shows all combinations of the basic data types and modifiers along with their size and range for a 16-bit word
machine
1.5 Variables
A variable is a named area in memory used to store values during program execution. Variables are run time entities. A
variable has a symbolic name and can be given a variety of values. When a variable is given a value, that value is actually placed
in the memory space assigned to the variable. All variables must be declared before they can be used. The general form of a
declaration is:

type variable_list;

Here, type must be a valid data type plus any modifiers, and variable_list may consist of one or more identifier names
separated by commas. Here are some declarations:

int i,j,l;

short int si;

unsigned int ui;

double balance, profit, loss;

1.6 Constants
Constants refer to fixed values that the program cannot alter. Constants can be of any of the basic data types. The way each
constant is represented depends upon its type. Constants are also called literals. We can use keyword const prefix to declare
constants with a specific type as follows:

const type variableName =

value; e.g.,

const int LENGTH = 10;

1.7 Operator
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in
operators. Generally, there are six type of operators: Arithmetical operators, Relational operators, Logical operators,
Assignment operators, Conditional operators, Comma operator.

Arithmetical operators

Arithmetical operators +, -, *, /, and % are used to performs an arithmetic (numeric) operation.

Operator Meaning
+ Addition

- Subtraction

* Multiplication

/ Division

% Modulus

You can use the operators +, -, *, and / with both integral and floating-point data types. Modulus or remainder % operator is
used only with the integral data type.

1.7.1 Relational operators


The relational operators are used to test the relation between two values. All relational operators are binary operators and
therefore require two operands. A relational expression returns zero when the relation is false and a non-zero when it is true.
The following table shows the relational operators.

Relational Operators Meaning

< Less than

<= Less than or equal to

== Equal to

> Greater than

>= Greater than or equal to

!= Not equal to

1.7.2 Logical operators


The logical operators are used to combine one or more relational expression. The logical operators are

Operators Meaning

|| OR

&& AND

! NOT

1.7.3 Assignment operator


The assignment operator '=' is used for assigning a variable to a value. This operator takes the expression on its right-
hand-side and places it into the variable on its left-hand-side.

For example:

m = 5;

The operator takes the expression on the right, 5, and stores it in the variable on the left,

m. x = y = z = 32;

This code stores the value 32 in each of the three variables x, y, and z. In addition to standard assignment operator
shown above, C++ also support compound assignment operators.

1.7.4 Compound Assignment Operators


Operator Example Equivalent to

+= A+=2 A=A+2

-= A-=2 A=A–2

%= A%=2 A=A%2

/= A/ = 2 A=A/2

*= A*=2 A = A *2

1.7.5 Increment and Decrement operator


C++ provides two special operators viz '++' and '--' for incrementing and decrementing the value of a variable by 1. The
increment/decrement operator can be used with any type of variable but it cannot be used with any constant.
Increment and decrement operators each have two forms, pre and post.

The syntax of the increment operator is: Pre-increment: ++variable

Post-increment: variable++

The syntax of the decrement operator is

Pre-decrement: ––variable Post-

decrement: variable–


In Prefix form first variable is first incremented/decremented, then evaluated In Postfix form first variable is first
evaluated, then incremented / decremented.

1.7.6 Conditional operator


The conditional operator ?: is called ternary operator as it requires three operands.

The format of the conditional operator is :

Conditional_ expression ? expression1 : expression2;

If the value of conditional expression is true then the expression1 is evaluated, otherwise expression2 is evaluated.

int a = 5, b = 6;

big = (a > b) ? a : b;

The condition evaluates to false, therefore big gets the value from b and it becomes 6.

1.7.7 The Comma Operator


The comma operator gives left to right evaluation of expressions. When the set of expressions has to be evaluated for a value,
only the rightmost expression is considered.

int a = 1, b = 2, c = 3, i; // comma acts as separator, not as an operator

i = (a, b); // stores b into i would first assign the value of a to i, and then assign value of b to variable i. So, at the end, variable i
would contain the value 2.

1.7.8 The sizeof Operator


The sizeof operator can be used to find how many bytes are required for an object to store in memory.

For example

sizeof (char) returns 1

sizeof (float) returns 4

1.8 Type Conversion


Typecasting is the concept of converting the value of one type into another type. For example, you might have a float that you
need to use in a function that requires an integer.

1.8.1 Implicit conversion


Almost every compiler makes use of what is called automatic typecasting. It automatically converts one type into another type.
If the compiler converts a type it will normally give a warning. For example this warning: conversion from ‘double’ to ‘int’,
possible loss of data.

The problem with this is, that you get a warning (normally you want to compile without warnings and errors) and you are not in
control. With control we mean, you did not decide to convert to another type, the compiler did.

Also the possible loss of data could be unwanted.

1.8.2 Explicit conversion


The C++ language have ways to give you back control. This can be done with what is called an explicit conversion.

Four typecast operators

The C++ language has four typecast operators:

▪ static_cast

▪ reinterpret_cast

▪ const_cast

▪ dynamic_cast

1.9 Type Casting


The Type Conversion is that which automatically converts the one data type into another but remember we can store a large
data type into the other. For example we can't store a float into int because a float is greater than int.

When a user can convert the one data type into then it is called as the type casting.

The type Conversion is performed by the compiler but a casting is done by the user for example converting a float into int.
When we use the Type Conversion then it is called the promotion.

In the type casting when we convert a large data type into another then it is called as the demotion. When we use the type
casting then we can loss some data.

1.10 Control Structures


The flow of program’s execution based on certain conditions C++ supports following basic control structures:

1) Selection Control structure

2) Loop Control structure

1.10.1 Selection Control structure:


Selection Control structures allows to control the flow of program’s execution depending upon the state of a particular
condition being true or false .C++ supports two types of selection statements :if and switch. Condition operator (?:) can also be
used as an alternative to the if statement.

1. If Statement

The syntax of an if statement in C++ is:

if(condition)

// statement(s) will execute if the condition is true

If the condition evaluates to true, then the block of code inside the if statement will be executed. If it evaluates to false, then
the first set of code after the end of the if statement (after the closing curly brace) will be executed .

Flowchart showing working of if statement


// A Program to find whether a given number is even or odd using if ….else statement

#include<iostream.h>

#include<conio.h>

int main()

int n ;

cout<<”enter number “;cin>>n;

if(n%2==0)

cout<<”Even number”;else

cout<<”Odd number”;return 0;

}
2.If…else Statement
The syntax is shown as:

(condition){

// statement(s) will execute if the condition is true

else{

// statement(s) will execute if condition is false

If the condition evaluates to true ,then the if block of code will be executed ,otherwise else block of code will be executed.

3.If ..else if…else Statement


An if statement can be followed by an optional else if …else statement,which is very useful to test various conditions using
single if…else if statement.

The Syntax is shown as :

if(condition 1){

//Executes when the condition 1 is true

else if(condition 2){

//Executes when the condition 2 is true

else if(condition 3){

//Executes when the condition 3 is true

else {

//Executes when the none of the above condition is true .

4.Nested if Statement
It is always legal to nest if-else statements , which means you can use one if or else if statement inside another if or else if
statement(s).

The syntax for a nested if statement is as

Follows: if(condition 1){

//Executes when the condition 1 is true if(condition 2){

//Executes when the condition 2 is true

}
1.10.2 Loop control structures
A loop statement allows us to execute a statement or group of statements multiple times. Loops or iterative statements tell the
program to repeat a fragment of code several times or as long as a certain condition holds. C++ provides three convenient
iterative statements: while, for, and do-while.

1. while loop

A while loop statement repeatedly executes a target statement as long as a given condition is true. It is an entry-controlled
loop.

The syntax of a while loop in C++ is:

while(condition){

statement(s);

Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is any
non-zero value. The loop iterates while the condition is true. After each execution of the loop, the value of test expression is
changed. When the condition becomes false, program control passes to the line immediately following the loop.

Flowchart

// A program to display numbers from 1 to 100


#include<iostream.h>

#include<conio.h>

int main(){

int i=1;

while(i<=100)

cout<<i;

i++;

return 0;

2. do while loop
The do-while loop differs from the while loop in that the condition is tested after the body of the loop.This assures that the
program goes through the iteration at least once. It is an exit-controlled loop.

do{

statement(s);

}while(condition);

The conditional expression appears at the end of the loop, so the statement(s) in the loop execute once before the condition is
tested .If the condition is true ,the flow of control jumps back up to do,and the statement(s) in the loop execute again. This
process repeats until the given condition becomes false .
// A program to display numbers from 1 to 100

#include<iostream.h>

#include<conio.h>

int main(){

int i=1;

do

cout<<i;

i++;

}while(i<=100);

return 0;

3. for loop
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of
times . The syntax of a for loop in C++ is :

for(int i; condition;increment)

statement(s);
}

// A program to display numbers from 1 to 100

#include<iostream.h>

#include<conio.h>

int main() {

int i;

for(i=1;i<=100;i++)

cout<< i;

return 0;

1.11 C++ Functions


A function groups a number of program statements into a unit and gives it a name. This unit can then be invoked from other
parts of the program. The function’s code is stored in only one place in memory, even though the function is executed many
times in the course of the program’s execution. Functions help to reduce the program size when same set of instructions are to
be executed again and again. A general function consists of three parts, namely, function declaration (or prototype), function
definition and function call.

Function declaration — prototype

A function has to be declared before using it, in a manner similar to variables and constants. A function declaration tells the
compiler about a function's name, return type, and parameters and how to call the function. The general form of a C++
function declaration is as follows:

return_type function_name( parameter list );

Function definition

The function definition is the actual body of the function. The function definition consists of two parts namely, function header
and function body.

The general form of a C++ function definition is as follows:

return_type function_name( parameter list )

{ body of the function }

Here, Return Type: A function may return a value. The return_type is the data type of the value the function returns. Some
functions perform the desired operations without returning a value. In this case, the return_type is the keyword void.

Function Name: This is the actual name of the function.

Parameters: A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is
referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a
function. Parameters are optional; that is, a function may contain no parameters.

Function Body: The function body contains a collection of statements that define what the function does.
1.12 Inline Functions
An inline function is a function that is expanded inline at the point at which it is invoked, instead of actually being called. The
reason that inline functions are an important addition to C++ is that they allow you to create very efficient code. Each time a
normal function is called,
a significant amount of overhead is generated by the calling and return mechanism. Typically, arguments are pushed onto the
stack and various registers are saved when a function is called, and then restored when the function returns. The trouble is that
these instructions take time.

However, when a function is expanded inline, none of those operations occur. Although expanding function calls in line can
produce faster run times, it can also result in larger code size because of duplicated code. The compiler can choose to ignore it.
Also, some compilers may not inline all types of functions. If a function cannot be inlined, it will simply be called as a normal
function.

A function can be defined as an inline function by prefixing the keyword inline to the function header as given below:

inline function header

{ function body }

int no, f;

cout<<”enter the positive number:-“;cin>>no;

f=factorial(no); //function call

cout<<”\The factorial of a number”<<no<<”is”<<f;return 0;

int factorial(int n)

{ int i,fact=1;for(i=1;i<=n;i++){fact=fact*i;

return fact;

// A program illustrating inline function

#include<iostream.h>

#include<conio.h>

inline int max(int x,int y)

{ if(x>y)
return x;

else

return y;

int main()

{ int a,b;

cout<<”enter two numbers”;

cin>>a>>b;

cout<<”The max is : “<<max(a,b)<<endl;

return 0;

1.12.1 Macros Vs inline functions


Preprocessor macros are just substitution patterns applied to your code. They can be used almost anywhere in your code
because they are replaced with their expansions before any compilation starts. Inline functions are actual functions whose
body is directly injected into their call site. They can only be used where a function call is appropriate.

inline functions are similar to macros (because the function code is expanded at the point of the call at compile time), inline
functions are parsed by the compiler, whereas macros are expanded by the preprocessor. As a result, there are several
important differences:

▪ Inline functions follow all the protocols of type safety enforced on normalfunctions.

▪ Inline functions are specified using the same syntax as any other function except that they include the inline keyword in the
functiondeclaration.

▪ Expressions passed as argumentsto inline functions are evaluated once.

▪ In some cases, expressions passed as arguments to macros can be evaluated more thanonce.

▪ macros are expanded at pre-compile time, you cannot use them for debugging, but you can use inline functions.
1.13 Reference Variable
A reference variable is an alias, that is, another name for an already existing variable. Once a reference is initialized with a
variable, either the variable name or the reference name may be used to refer to the variable. To declare a reference variable
or parameter, precede the variable's name with the &. The syntax for declaring a reference variable is:

datatype &Ref = variable name;

Example:

int main(){

int var1=10; //declaring simple

variable int & var2=var1; //declaring

reference variable cout<<”\n value of var2 =”<<var 2;

return 0;

var2 is a reference variable to var1.Hence, var2 is an alternate name to var1.This code prints the value of var2 exactly as that of
var1.

1.14 Call by Reference

Arguments can be passed to functions in one of two ways: using call-by-value or call-byreference. When using call-by-value, a
copy of the argument is passed to the function. Callby-reference passes the address of the argument to the function. By
default, C++ uses call-byvalue.
Provision of the reference variables in c++ permits us to pass parameter to the functions by reference. When we pass
arguments by reference, the formal arguments in the called function become aliases to the actual arguments in the calling
function. This means that when the function is working with its own arguments, it is actually working on the original data.

Example

#include<iostream.h>

#include<conio.h>

void swap(int &x,int &y); //function declaration

int main() {

int a=10,b=20;

cout<<”Before swapping”<<endl;

cout<<”value of a:”<<a<<”value of b :”<<b<<endl;

swap(a,b); //calling a function to swap the values.

cout<<”After swapping”<<endl;

cout<<value of a :”<<a<<”value of b :”<<b<<endl;

return 0;

void swap(int &x,int &y){

int temp;

temp=x; //function definition to swap the values.

x=y;

y=temp;

Default arguments are useful if you don’t want to go to the trouble of writing arguments that, for example, almost always have
the same value. They are also useful in cases where, after a program is written, the programmer decides to increase the
capability of a function by adding another argument. Using default arguments means that the existing function calls can
continue to use the old number of arguments, while new function calls can use more.

Example

#include <iostream.h>

#include<conio.h>

int sum(int a,int b=20){

return(a+b);

int main(){

int a=100,b=200,result;

result =sum(a,b); //here a=100,b=200

cout<<”Total value is : ”<<result<<endl;

result = sum(a); //here a=100,b=20(using default value)

cout<<”Total value is :”<<result<<endl;

return 0;

1.15 Class

A class is a user defined data type. A class is a logical abstraction. It is a template that defines the form of an object. A class
specifies both code and data. It is not until an object of that class has been created that a physical representation of that class
exists in memory. When you define a class, you declare the data that it contains and the code that operates on that data. Data
is contained in instance variables defined by the class known as data members, and code is contained in functions known as
member functions. The code and data that constitute a class are called members of the class. The general form of class
declaration is:

class class-name {

access-specifier:

data and functions


access-specifier:

data and functions

// ...

access-specifier:

data and functions

} object-list;

The object-list is optional. If present, it declares objects of the class. Here, access-specifier is one of these three C++ keywords:

Public private protected

By default, functions and data declared within a class are private to that class and may be accessed only by other members of
the class. The public access specifier allows functions or data to be accessible to other parts of your program. The protected
access specifier is needed only when inheritance is involved.

Example :

#include<iostream.h>

#include<conio.h>

class myclass { // class declaration

// private members to myclass

void set_a(int num);

int get_a();

};

1.16 Object
An object is an identifiable entity with specific characteristics and behavior. An object is said to be an instance of a class.
Defining an object is similar to defining a variable of any data type: Space is set aside for it in memory. Defining objects in this
way means creating them. This is also called instantiating them. Once a Class has been declared, we can create objects of that
Class by using the class Name like any other built-in type variable as shown:

className

objectName Example

void main( ) {
myclass ob1, ob2; //these are object of type myclass

//…program code

The main() cannot contain statements that access class members directly. Class members can be accessed only by an object of
that class. To access class members, use the dot (.) operator. The dot operator links the name of an object with the name of a
member. The general form of the dot operator is shown here:

object.member

Example

ob1.set_a(10);

The private members of a class cannot be accessed directly using the dot operator, but through the member functions of that
class providing data hiding. A member function can call another member function directly ,without using the dot operator.

C++ program to find sum of two numbers using classes

#include<iostream.h>

#include<conio.h>

class A{

int a,b,c;

public :

void sum(){

cout<<”enter two numbers”;

cin>>a>>b;

c=a+b;

cout<<”sum=”<<c;

};

int main(){

A u;

u.sum();
getch();

return 0;

1.17 Scope Resolution Operator


Member functions can be defined within the class definition or separately using scope resolution operator (::). Defining a
member function within the class definition declares the function inline, even if you do not use the inline specifier. Defining a
member function using scope resolution operator uses following declaration

return-type class-name::func-name(parameter- list)

// body of function

Here the class-name is the name of the class to which the function belongs. The scope resolution operator (::) tells the
compiler that the function func-name belongs to the class classname. That is, the scope of the function is restricted to the
class-name specified.

Class my class { int a;

public:

void set_a(int num); //member function declaration

int get_a( ); //member function declaration


};

//member function definition outside class using scope resolution

operator void myclass :: set_a(int num)

a=num;

int myclass::get_a( )

{ return a; }

Another use of scope resolution operator is to allow access to the global version of a variable. In many situation, it happens
that the name of global variable and the name of the local variable are same .

1.18 Pointer
A pointer is a variable that contains a memory address. Very often this address is the location of another object, such as a
variable. For example, if x contains the address of y, then x is said to “point to” y. Pointer variables must be declared as such.
The general form of a pointer variable declaration is

type *var-name;

Here, type is the pointer’s base type. The base type determines what type of data the pointer will be pointing to. var-name is
the name of the pointer variable.

To use pointer:

• We define a pointer variable.

• Assign the address of a variable to a pointer.

• Finally access the value at the address available in the pointer variable. This is done by using unary operator * that returns
the value of the variable located at the address specified by its operand.

Example:
// normal variable

int a =10;

int *p ; // declare pointer

p=&a; // Assign the address of a variable “a” to a

pointer “p” cout<<”a=”<<*p; //prints a=10

Chapter 2
2.Introduction to project
Project for Customer Payment and billing System in C++ with code- This C++ grocery store billing system is a straightforward
console program without any visuals .You will learn how to use the stream class and manage files in the C++ programming
language with this project.

What is exactly a Supermarket Bill?

The supermarket billing system is intended to help supermarkets calculate and show invoices,as well as provides faster and
more effective customer service.The user interface of this software solution is both efficient and user-friendly ,helping staff
members with customer service bill calculation.

What Functions Do Billing System Serves?


By ensuring that the billing system is transparent and that the precise amount has been stated for the purchases ,the
supermarket billing system helps to preserve a good connection between the customer and the shop management . It enables
and Guarantees consumer payment.

Import the Necessary Libraries

Identifying the C++ libraries that our software will require as a first step. At the commencement of the presentation, these will
be given. The header files are imported using #include from a library ,iostream is the first library that our app needs .We will
use this library to manage our supermarket billing project using C++ basic input and output.

Main purpose
A Billing system is a software application that is used to manage the process of invoicing and payment collection for products
or or services provided by a business . The purpose of a billing system is to automate the billing process ,making it more
efficient and accurate .

The main purpose of billing system is to streamline the billing process for a business , making it easier to generate invoices and
collect payment from the customer . The system can be used to generate invoices ,track payments ,and generate reports on
billing activity.

Overall, the purpose of billing system is to improve the efficiency and accuracy of the billing process ,making it easier for a
business to manage its finances and provide quality service to its customers .

What to expect ?
Here are some features that Customer Payment and Billing System Shows -

1. New Entry
2. To View Previous Entry
3. Exit
New Entry :- If a new customer buy something then the record of the items and the payment record is shown by this project.To
view previous Entry :- If one customer or owner wants to know the list of items bieng sold ,he can use the previous entries to
calculate details.Exit :- To exit from the project , there will be an exit option .

SOURCE CODE:
OUTPUT:

You might also like