24CS101 Unit - I
24CS101 Unit - I
This document is confidential and intended solely for the educational purpose of RMK
Group of Educational Institutions. If you have received this document through email in
error, please notify the system manager. This document contains proprietary information
and is intended only to the respective group / learning community as intended. If you
are not the addressee you should not disseminate, distribute or copy through e-mail.
Please notify the sender immediately by e-mail if you have received this document by
mistake and delete this document from your system. If you are not the intended
recipient you are notified that disclosing, copying, distributing or taking any action in
reliance on the contents of this information is strictly prohibited.
24CS101
Programming in C++
Department :CSE, IT
Batch / Year : 2024 – 2028 / I
Created by : Subject Handling Faculties
Date : 20.09.2024
1.CONTENTS
S.NO CONTENTS
1 Contents
2 Course Objectives
3 Prerequisites
4 Syllabus
5 Course Outcomes
6 CO-PO Mapping
7 Lecture Plan
9 Lecture Notes
10 Assignments
12 Part-B Questions
16 Assessment Schedule
1.8 operators
1.9 Expressions
1.16 Strings
1. Imagine you are working as a software engineer at a tech company. Your team is
developing a mathematical software library that will be used in various applications
across the company. One of the features that your team lead has asked you to
implement is a function that calculates the number of trailing zeros in the factorial of a
number.
The team lead has emphasized the importance of encapsulation in your
implementation.
2. Create a C++ class Calculator representing a simple calculator. The class should have
the following attributes and methods:
List of Exercise/Experiments:
1. Write a Program to Demonstrate the i) Operator Overloading. ii) Function Overloading.
2. Write a Program to Demonstrate Friend Function and Friend Class.
3. Program to demonstrate inline functions.
4. Program for Overriding of member functions.
5. Write C++ programs that illustrate how the following forms of inheritance are
supported:
a) Single inheritance b) Multiple inheritance c) Multi level inheritance d) Hierarchical
inheritance.
Practice Questions & Scenario Based Questions:
1. Joy is a software developer at a 3D modeling company. The company is developing a
new software tool that will be used by architects and engineers to design and analyze
3D models of various structures. One of the features that her project manager has
asked is to implement a function that calculates the volume of basic 3D shapes like
cylinders and cuboids. The project manager has emphasized the importance of using
function overloading in her implementation..
2. Imagine you are a software developer tasked with creating a utility program for a school
that handles student scores. The school wants a simple program where teachers can
enter the scores of students for a particular test, and the program will then provide the
highest and lowest scores among them. This will help the teachers quickly identify the
top performer and the student who might need extra help.
Your task is to write program that satisfies the above scenario using inline function
3. Develop a software system to manage part-time worker students at a university. These
students have unique attributes such as their name, student ID, hourly wage, and
hours worked per week. Your goal is to create a C++ program that models this system.
3 Ramu is a software developer at a company specializing in developing software
solutions for geometric shapes. Recently, a client approached with a request to
create a program to calculate the areas of rectangles and triangles.
List of Exercise/Experiments:
1. Program to demonstrate pure virtual function implementation.
2. Count the number of account holders whose balance is less than the minimum balance
using sequential access file.
3. Write a Program to Demonstrate the Catching of all Exceptions.
Practice Questions & Scenario Based Questions:
1. Develop a simple library management system. Create a base class Book representing
a book in the library. The class should have attributes such as title, author, and ISBN
(International Standard Book Number). Implement a virtual function displayDetails() to
display information about the book.
2. A software developer working on a banking application. One of the requirements is to
analyze account holders' balances based on a minimum balance threshold. The
application should read account information from a sequential access file, where each
line represents an account record in the format: account_holder_name, balance.
3. The financial company is developing a new software tool that will be used by financial
analysts to perform various calculations. One of the features of that project is to
implement is a function that performs division of two numbers.
Write a program that takes two integer inputs, numerator and denominator, from the
user. Implement error handling to check if the denominator is zero. If the denominator
is zero, display the message "Division by zero is not allowed!" using an exception. If
the denominator is not zero, calculate the result of the division and display it.
4. Mini project.
TOTAL: 45 (L) + 45 (P) = 90 PERIODS
OUTCOMES:
Upon completion of the course, the students will be able to:
CO1: Solve problems using basic constructs in C++.
CO2: Implement C++ programs using pointers and functions.
CO3: Apply object-oriented concepts and solve real world problems.
CO4: Develop C++ programs using operator overloading and polymorphism.
CO5: Implement C++ programs using Files and exceptions.
CO6: Develop applications using C++ concepts
TEXT BOOKS:
1. Herbert Schildt, “The Complete Reference C++”, 4th edition, MH, 2015.
2. E Balagurusamy,” Object Oriented Programming with C++”, 4th Edition, Tata McGraw-
Hill Education, 2008.
REFERENCES:
1. Karl Beecher,” Computational Thinking: A beginner's guide to problem-solving and
programming”, BCS Learning & Development Ltd, 2017. (Unit 1)
2. Nell Dale, Chip Weems, “Programming and Problem Solving with C++”, 5th Edition,
Jones and Barklett Publishers, 2010.
3. John Hubbard, “Schaum's Outline of Programming with C++”, MH, 2016.
4. Yashavant P. Kanetkar, “Let us C++”, BPB Publications, 2020
5. ISRD Group, “Introduction to Object-oriented Programming and C++”, Tata McGraw-
Hill Publishing Company Ltd., 2007.
6. D. S. Malik, “C++ Programming: From Problem Analysis to Program Design”, Third
Edition, Thomson Course Technology, 2007.
7. Paul Deitel, Harvey Deitel, “C++ How to Program”, 10th Edition, Pearson Education
Inc. 2017.
8. https://infyspringboard.onwingspan.com/web/en/app/toc/
lex_auth_01297200240671948837_shared/overview
LIST OF EQUIPMENTS:
1. Standalone desktops with C/C++ compiler (or) Server with C/C++ compiler.
5. Course Outcomes
PO PO PO PO PO PO PO PO PO PO PO PO PS PS PS
COs 1 2 3 4 5 6 7 8 9 10 11 12 O1 O2 O3
CO1 3 2 1 2 1
CO2 3 2 1 2 1
CO3 3 2 1 2 1
CO4 3 3 3 2 1
CO5 3 2 1 2 1
CO6 3 3 3 1 1 1 2 1
1
7. Lecture Plan - Unit I
Procedural Programming
Adding new data and functions is not easy. Adding new data and function is easy.
Procedural programming does not have any proper Object-oriented programming provides data
way of hiding data so it is less secure. hiding so it is more secure.
Procedural programming uses the concept of Object-oriented programming uses the concept
procedure abstraction. of data abstraction.
Examples: C, FORTRAN, Pascal, Basic, etc. Examples: C++, Java, Python, C#, etc.
Types of computer programming languages
Programming Language :
b. Assembly Language:-
• Assembly Language is a symbolic programming language.
• It uses letter codes instead of binary digits.
• These letter codes are alphabetical abbreviation, known as Mnemonics
• For example- For Addition, the Mnemonics ADD may be used.
• other examples are For Subtraction, the Mnemonics SUB, For Multiply, the
Mnemonics MULT, For Divide, the Mnemonics DIV and so on may be used.
• TYPES:
• Procedural Oriented programming language
• The advantage of POP language is that it helps programmers to easily track the
program flow and code can be reused in different parts of the program.
• Example:
• C
• FORTRAN
• Basic
• Pascal, etc.
b. Object-Oriented Programming language
this programming language, programs are divided into small parts called objects.
abstraction, etc in the program to makes the program re-usable, efficient, and
easy-to-use.
• C++ was developed by Bjarne Stroustrup at Bell Laboratories over a period starting in
1979.
• Since C++ is an attempt to add object-oriented features (plus other improvements)
to C, earlier it was called “C with Objects”.
• As the language developed, Stroustrup named it C++ in 1983.
• It was developed to add a feature of OOP (Object Oriented Programming) in C
without significantly changing the C component.
• Stroustrup was inspired by the Simula programming language, which was one of
the first object-oriented languages. He wanted to create a language that had the
same features as Simula, but that was also as efficient as C.
• C++ was originally developed as an extension to the C language. It added a number
of new features to C, including object-oriented programming, generic programming,
and exception handling.
• C++ quickly became one of the most popular programming languages in the world. It
is used to develop a wide variety of applications, including operating systems, games,
and embedded systems.
The below images show some valid and invalid C++ identifiers.
C++ Variables
C++ Keywords
❖ Step 1 − Divide the decimal number to be converted by the value of the new
base.
❖ Step 2 − Get the remainder from Step 1 as the rightmost digit (least
significant digit) of new base number.
❖ Step 3 − Divide the quotient of the previous divide by the new base.
❖ Step 4 − Record the remainder from Step 3 as the next digit (to the left) of
the new base number.
❖ Repeat Steps 3 and 4, getting remainders from right to left, until the quotient
becomes zero in Step 3.
❖ The last remainder thus obtained will be the Most Significant Digit (MSD) of
the new base number.
Conversion from Decimal To
✔ Binary
✔ Octal
✔ Hexadecimal
✔ 1.Decimal to Binary Conversion
Convert 108.18810 into binary number.
.18810 = .001102
108.18810 = 1101100.001102
10810 = 11011002
✔ 2.Decimal to Octal Conversion
247910 = 9AF16
.56510 = .90A3D7016
2479.56510 = 9AF.90A3D7016
BINARY TO OTHER BASE SYSTEM
✔ Decimal
✔ Octal
✔ Hexadecimal
11011011.10112= 219.687510
✔ 2.Binary to Octal Conversion
Convert 1010111100.10112 into Octal number.
1010111100.10112= 1274.548
✔ 3.Binary to Hexadecimal Conversion
Convert 11111011101110010.0111010101011112 into Hexadecimal number.
11111011101110010.0111010101011112 = 1F772.655EH
OCTAL TO OTHER BASE SYSTEM
✔ Decimal
✔ Binary
✔ Hexadecimal
1.Octal to Decimal Conversion
Convert 1725.438 into decimal number.
1725.438= 981.54687510
165128=
749810
✔ 2.Octal to Binary Conversion
Convert 35.3468 into Binary number.
35.3468= 001101.0111001102
✔ 3.Octal to Hexadecimal Conversion
54.D216= 84.820312510
✔ 2. Hexadecimal to Binary Conversion
Convert A12C16 into binary number.
A12C16= 10100001001011002
✔ 3. Hexadecimal to Octal Conversion
Convert 1A16 into Octal number.
1A16= 328
Convert A4B.59E16 into Octal number
A4B.59E16= 5113.26368
1.7 Data types in C++
• A data type is the type of data a variable can hold. For example, a Boolean
variable can have boolean data, and an integer variable can hold integer data.
• Variables are just storage locations reserved for storing values. Therefore when
we declare the variable, some space in memory will be reserved.
• You may want to store information for different data types, such as integers,
floats, strings, and Boolean values.
• Memory is allocated based on the variable's data type. The amount of memory
required depends on the data type.
score here is an int datatype variable. The variable score can only store 2-
byte or 4-byte integers, depending on the compiler/system.
3. Boolean
The boolean data type's keyword is bool. True or false are the two possible values for
the boolean data type. Boolean values are generally used in conditional statements
and loops.
For example,
bool is_true = true;
is_true here is a boolean data type variable. This means that the variable requires 1
byte of memory space.
4. Floating Point
float is the keyword used to hold floating-point numbers (decimals and exponentials).
The float variable has a size of 4 bytes.
For example,
float val = 15.26;
val here is a floating-point datatype variable. This means that the variable requires 4
bytes of memory space.
5. Double Floating Point
• double is the keyword used to hold floating-point numbers (decimals and
exponentials) with double precision. The double variable has a size of 8
bytes.
For example,
double val = 2019.1526;
val here is a double floating-point datatype variable. This means that the
variable requires 8 bytes of memory space.
6. Void or Valueless
• The term void refers to something that has no worth. The void data type
represents a valueless entity. Variables of the void type cannot be declared.
It is only used for functions, not returning any data.
7. Wide Character
• The wide-character wchar_t data type is similar to the char data type, but
its size is 2 or 4 bytes rather than 1 byte. It's used to represent characters
that take up more memory than a single char to represent.
For example,
wchar_t w = L'C';
w here is a wide-character datatype variable that has a value of
67 (L'C') and has a size of 4 bytes. This means that the variable requires 2
bytes or 4 bytes of memory space.
Derived Data types in C++
• Derived Data Types are data types that are created by combining primitive or
built-in datatypes. There are four different types of derived data types. These are :
1. Function
• A function is a code segment or a block of code defined to accomplish a specific
purpose.
• A function is often designed to spare the user from repeatedly writing the same
lines of code for the same input.
• All the lines of code are combined into a single function that may be invoked from
anywhere. Every C++ application includes a default function called main().
• The function also has a return type, which is used to specify the type of data
the function would return when its execution is complete.
• The function's return type could be any data type, including the void, which
states that there is no need to return anything once the execution of that
function is complete.
Syntax:
function_return_type function_name(parameters) { }
Example:
int sum(int num1, int num2) { return (num1 + num2); }
Here, the return type of the sum function is an integer, and the function is
used to calculate the sum of 2 numbers.
2. Array
• An array is a set of elements that are kept in memory in a continuous manner
and also have the same type of data present within the array. The purpose of
an array is to store a lot of data in a single variable name and sequential
order.
Syntax:
datatype array_name[size_of_array];
Example:
int arr[4]={0,1,2,3};
Here, we have defined an integer array of size 4, which can continuously
store four integer variables in memory.
3. Pointer
• Pointers are symbolic representations of addresses.
• Pointers store the addresses of the variables having the same datatype as
that of the pointer.
• The size of the pointer is either 4 bytes or 8 bytes, no matter what the data
type is.
• They enable programs to create and change dynamic data structures, as well
as to imitate call-by-reference.
• In C++, its generic declaration looks like this:
Syntax:
data_type* variable_name;
Example:
int* point_int;
point_int holds the address of a variable of an integer datatype.
4. Reference
When we declare a variable as a reference, it becomes an alternate name
for an existing variable. By adding '&' to a variable's declaration, it can be
declared as a reference.
Example:
int val = 1526; int &ref = val;
Here ref becomes the reference to integer val, and now any
changes in one would be automatically reflected in the other as they both
represent the same memory location.
4. Enumeration
Enumeration (or enum) is a user-defined data type in C. It is mainly used to
assign names to integral constants, the names make a program easy to read and
maintain.
Syntax
enum nameOfEnum
{
varName1 = 1, varName2 = 0
};
Eg:
enum week { Mon, Tue, Wed, Thur, Fri, Sat, Sun };
int main()
{
enum week day;
day = Wed;
cout << day;
return 0;
}
Output: 2
5. Typedef
C++ allows you to define explicitly new data type names by using the
keyword typedef. Using typedef does not create a new data class, rather it
defines a name for an existing type. This can increase the portability(the ability
of a program to be used across different types of machines.
Syntax
typedef typeName;
Constants in C++
The const keyword (which stands for constant) is used to specify that the value
of a variable cannot be changed anywhere in the program, either intentionally or
accidentally. For example,
const double PI = 3.14; // makes PI a constant
Note: The standard naming convention for constants is that they must all be in
uppercase letters. For example,
#include <iostream>
using namespace std;
void main()
{
int x = 10;
int y = 15;
#include <bits/stdc++.h>
using namespace std;
int main()
{
int i = 0;
No output
5. Semantic errors
This error occurs when the statements written in the program are not meaningful to
the compiler.
int main()
{
int a, b, c;
a + b = c; //semantic error
}
1) Arithmetic Operators
• Unary Operator
• Binary Operator
a) Unary Operator
• Unary arithmetic operator in C++ is used only with one operand to perform the
arithmetic operations.
• The increment operators are used to increment the value of a variable by 1, and
decrement operators are used to decrement the value of a variable by 1.
• Pre-increment or pre-decrement operators first manipulate the value and then
get assigned to the variables, whereas post-increment or post-decrement
operators first get assigned to the variable, and then the value gets
manipulated.
a)Unary Operators
#include <iostream>
using namespace std;
int main()
{
int x;
int a = 5;
x = a++; // post increment
cout << "value of x is " << x << ", value of a is " << a << endl;
x = ++a; // pre increment
cout << "value of x is " << x << ", value of a is " << a << endl;
x = a--; // post decrement
cout << "value of x is " << x << ", value of a is " << a << endl;
x = --a; // pre decrement
cout << "value of x is " << x << ", value of a is " << a << endl;
return 0;
}
Output:
value of x is 5, value of a is 6
value of x is 7, value of a is 7
value of x is 7, value of a is 6
value of x is 5, value of a is 5
b) Binary Operator
The binary arithmetic operators are the ones that are used with 2 operands
to perform the arithmetic operations.
Example Program :
#include <iostream>
using namespace std;
int main()
{ OUTPUT:
int a = 8, b = 3;
// Addition operator a + b = 11
cout << "a + b = " << (a + b) << endl; a-b=5
// Subtraction operator a * b = 24
cout << "a - b = " << (a - b) << endl; a/b=2
// Multiplication operator a%b=2
cout << "a * b = " << (a * b) << endl;
// Division operator
cout << "a / b = " << (a / b) << endl;
// Modulo operator
cout << "a % b = " << (a % b) << endl;
return 0;
}
2. Relational operators
Relational operators are mainly used to check for specific conditions. These are always
binary operators because 2 operands are needed to evaluate the condition. If the
condition is true, it will return 1, else if the condition is false, it will return 0.
Example Program :
#include <iostream>
using namespace std;
int main()
{
int a = 6, b = 4;
cout << "a == b is " << (a == b) << endl; // Equal to operator
cout << "a > b is " << (a > b) << endl; // Greater than operator
cout << "a >= b is " << (a >= b) << endl; // Greater than or Equal to operator
cout << "a < b is " << (a < b) << endl; // Lesser than operator
cout << "a <= b is " << (a <= b) << endl; // Lesser than or Equal to operator
cout << "a != b is " << (a != b) << endl; // true
return 0;
}
Output:
a == b is 0
a > b is 1
a >= b is 1
a < b is 0
a <= b is 0
a != b is 1
Output:
a && b is 1
a ! b is 1
!b is 0
4. Bitwise operators
• Bitwise operators are fundamental to systems programming, enabling
manipulation of data at the bit level, which can lead to more efficient code.
These operators are used to perform operations on binary representations of
numbers, where the operations are carried out bit by bit.
Bitwise AND:
• Suppose if there are two bits, bit 1 and bit 2, Two-Bits are there then:
1. If bit 1 and bit 2 both are 0 then bit 1 & bit 2 will also be 0.
2. If bit 1 is 1 and bit 2 is 0 then bit 1 & bit 2 will be 0.
3. If bit 1 is 0 and bit 2 is 1 then bit 1 & bit 2 will be 0.
4. If bit 1 and bit 2 both are 1 then only bit 1 & bit 2 will be 1.
Bitwise OR:
• Here we can see in the table that Bit 1 | Bit 2 will be 1 if any one of the bits is
1. And Bit 1 | Bit 2 will be 0 if both the bits are 0.
• Then, if both the bits are different then only Bit 1 ^ Bit 2 will be 1. If Bit
1 and Bit 2 are the same then Bit 1 ^ Bit 2 will be 0.
• The other bit must be 0 or if one bit is 0 then the other bit must be 1
then only Bit 1 ^ Bit 2 will be 1.
Bitwise NOT
• NOT is a unary operation that means an operation with only one operand.
In this operation,
• Here you can see that the NOT inverts the bits of its operant. If the bit is
1 then NOT will be 0 and if the bit is 0 then NOT will be 1.
In the Left shift, we have to shift all the bits to the left-hand side by the value
given by the user. In this case, we will shift all the bits by one to the left-hand
side as:
• If we write x >> i (i is some number here) then x will be divided by 2i. Now
it will be 2 in decimal form. Let’s see these all operations in code.
• Note: Binary left shift shifts the bits to the left side as the number of times you
specified. Mainly it will do multiplication.
• Binary Right Shift shifts the bits to the Right side as the number of times you
specified. Mainly it will do division.
• Example Program :
• #include<iostream>
using namespace std;
int main ()
{
int a = 10, b = 13;
cout << "Bitwise AND: \t" << (a & b) << endl;
cout << "Bitwise OR: \t" << (a | b) << endl;
cout << "Bitwise X-OR: \t" << (a ^ b) << endl;
cout << "Bitwise NOt A: \t" << ~a << endl;
cout << "Bitwise Not B: \t" << ~b << endl;
a = a << 2;
cout << "Bitwise leftshift of a:\t" << a << endl;
b = b >> 2;
cout << "Bitwise Rightshift of b:\t" << b << endl;
return 0;
}
OUTPUT :
Assignment Operators
• These operators are used to assign value to a variable. For example: num = 6
will assign the value 6 to the variable num.
• The left side operand of the assignment operator is a variable and the right
side operand of the assignment operator is a value.
• The value on the right side must be of the same data type as the variable on
the left side otherwise the compiler will raise an error.
Ternary operator or Conditional operator :
• The ternary operator in c++, often denoted as "? :", is a concise way to express
conditional logic in many programming languages. It takes three operands:
(condition) ? Expression1 or value1: Expression2 or value2
Here's how it works:
• The condition (condition) is verified first.
• If the condition is true, the value of Expression1 is returned.
• If the condition is false, the value of Expression2 is returned.
Example Program :
#include<iostream>
using namespace std;
int main()
{
int num=10;
string result;
result=(num>5)? “Greater than 5” :” less than or equal to 5 “;
cout<<result;
Output:Greater than 5
return 0;
A type cast is basically a conversion from one type to another. There are two
types of type conversion:
• This process is also called type casting and it is user-defined. Here the user can
typecast the result to make it of a particular data type.
• Converting by assignment: This is done by explicitly defining the required type in
front of the expression in parenthesis. This can be also considered as forceful
casting.
• Syntax:
(type) expression
where type indicates the data type to which the final result is converted.
Example Program :
#include <iostream>
using namespace std;
int main()
{
double x = 1.2;
Sum = 2
cout << "Sum = " << sum;
return 0;
}
1.11Control-Flow Statements - Conditional Statements
Conditional statements in programming are used to control the flow of a program based
on certain conditions.
These statements allow the execution of different code blocks depending on whether a
specified condition evaluates to true or false, providing a fundamental mechanism
for decision-making in algorithms.
If Statements
Simple if conditional
statements
The if statement is the most basic form of conditional statement. It checks if a condition is
true. If it is, the program executes a block of code.
Syntax of If Conditional Statement:
if (condition)
{
// code to execute if condition is true
}
if condition is true, the if code block executes. If false, the execution moves to the next
block to check.
Example Program :
#include <iostream>
using namespace std;
int main()
{
int x = 10;
if (x > 0) OUTPUT:
{
cout<<"x is positive"; x is positive
}
return 0;
}
if .. else statement
If the test condition is evaluated to true, statements inside the body of if are
executed.
If the test condition is evaluated to false, statements inside the body of else
are executed.
if (condition)
{
// code to execute if condition is true
}
else
{
// code to execute if condition is false
}
Example program for if-else statement
#include <iostream>
using namespace std;
int main()
{
int x = -10;
if (x > 0)
{
cout << "x is positive";
}
else
{
cout << "x is not positive";
}
return 0;
}
Nested if.. else
One if ..else statement is available , either in if block or else block , is termed as
Nested if-else statement.
Syntax
if(condition1)
{
// Code to be executed
if(condition2)
{
// Code to be executed
}
else
{
// Code to be executed
}
}
else
{
// code to be executed
}
//program for nested ..if else
#include <iostream>
using namespace std;
int main()
{
int x = 0;
if (x > 0)
{
cout << "x is positive"; OUTPUT:
} x is zero
else if (x < 0)
{
cout << "x is not positive";
}
else {
cout << "x is zero";
}
return 0;
}
else if ladder:
When a series of many conditions have to be checked use the else if ladder
statement, which takes the following general form.
if (condition1)
statement1;
else if (condition2)
statement2;
else if (condition3)
statement3;
else if (condition-n)
statement n;
else
default statement;
Example:
#include <iostream>
using namespace std;
int main()
{
int day;
cout << "Enter Day Number: ";
cin >> day;
cout << "Day is ";
if (day == 1)
cout << "Sunday" << endl;
else if (day == 2)
cout << "Monday" << endl;
else if (day == 3)
cout << "Tuesday" << endl;
else if (day == 4)
cout << "Wednesday" << endl;
else if (day == 5)
cout << "Thursday" << endl;
else if (day == 6)
cout << "Friday" << endl;
else
cout << "Saturday" << endl;
return 0;
}
Output:
Enter Day Number : 5
Thursday
Switch Statement
⮚ It is a multi-way branch statement.
⮚ It requires only one argument of any data type, which is checked with number
of case option.
⮚ switch() statement evaluates expression and then for values among the case
constants.
⮚ If the value matches with case constant, the particular case statement is
executed, if not default is executed.
⮚ switch, case and default are reserved keywords.
⮚ Every case statement terminates with ':'.
⮚ The break statement is used to exit from the current case structure.
Syntax:
switch (expression or value)
{
case value-1:
block-1;
break;
case value-2;
block-2;
break;
.
.
.
default:
default-block;
}
⮚ The expression is an integer expression or character.
⮚ value-1, value-2 is constants or constant expressions and is known as case
labels.
⮚ These values should be unique within a switch statement.
⮚ block-1, block-2… are statement lists.
When the switch is executed, the value of the expression is successively compared
against the values value-1, value-2…
If a case is found, whose value matches with the value of the expression, and then
the block of statements that follows the case is executed.
The break statement, transfers the control to the statement-x following the switch.
Default is an optional case.
example of a switch case statement
#include <iostream>;
using namespace std;
int main()
{
int x = 2;
switch (x) { OUTPUT:
case 1:
cout << "x is one";
x is two
break;
case 2:
cout << "x is two";
break;
default:
cout << "x is neither one nor two";
}
return 0;
}
1.12 Iterative Statements / Looping statements :
For Loop
• A For loop is a repetition control structure that allows us to write a loop that is
executed a specific number of times. The loop enables us to perform n number
of steps together in one line.
Syntax:
return 0;
}
Output
Hello World
Hello World
Hello World
Hello World
Hello World
While loop
• While loop is a type of the entry controlled loop which initially checks the
condition and if the condition is true, then execute the loop body. It is basically
used when the count of iterations is not fixed.
Syntax
The C++ language provides the following syntax for the while loop:
update expression;
}
• The various parts of the While loop are:
1. Test Expression: In this expression, we have to test the condition. If the
condition evaluates to true then we will execute the body of the loop and go to
update expression. Otherwise, we will exit from the while loop.
2. Update Expression: After executing the loop body, this expression
increments/decrements the loop variable by some value.
3.Body: This is a group of statements that include variables, functions, and so on.
With the while loop, code, and simple names can be printed, complex algorithms
can be executed, or functional operations can be performed.
• According to the syntax, the body will be executed first at least once without
checking whether it is true or false.
#include <iostream>
using namespace std;
int main() {
int num = 1; // Initializing variable num.
do {
// Body of the loop. Output:
cout << "Scaler Topics" << endl;
Scaler Topics
num++; // Update_expression. Scaler Topics
}
while (num < 3); // test_expression.
return 0;
}
1.13 Unconditional control statements
Unconditional control statements in C++ are used to transfer control from one
part of the program to another without any conditions.
Here are the main types:
1. goto Statement: This statement directs the program control to a labeled
statement within the same function. It's generally advised to avoid using `goto` as
it can make the code harder to read and maintain.
goto label;
// some code
label:
// code to execute
#include <iostream>
using namespace std;
int main() {
int num = 0; // Initializing num variable.
start: // Defining the label.
cout << num << endl;
num++; // Incrementing num variable.
// Checking condition.
if (num < 10) {
// If true, execute the goto statement, and move to label "start".
goto start;
}
cout << "End Reached"; // Finally printing
return 0;
}
Output:
0
1
2
3
4
5
6
7
8
9
End Reached
Output:
0
1
2
3
4
return 0;
}
Output :
0
1
2
3
4
6
7
8
9
1.14 Arrays
Arrays – Introduction, Declaration, Initialization, Input, Output
Introduction
An array is a group (or collection) of same data types. For example an int array holds the
elements of int types while a float array holds the elements of float types.
Consider a scenario where you need to find out the average of 100 integer numbers
entered by user. There are two ways to do this:
1)Define 100 variables with int data type and then perform 100 scanf() operations to
store the entered values in the variables and then at last calculate the average of them.
2) Have a single integer array to store all the values, loop the array to store all the
entered values in array and later calculate the average.
Which solution is better? Obviously the second solution, it is convenient to store same
data types in one single variable and later access them using array index.
26 89 15 39 57
If the number of values provided is less than the number of Elements in the array, the
un-assigned elements are filled with zeros.
Types of array :
• 1. one dimensional array
Syntax : datatype arraymane[size]; eg: int a[10];
• 2.Two dimensional array - to store the matrix inputs.(table of values having rows and
columns)
syntax :
datatype arrayname[size1][size2];
int a[2][3]; - 6 nos - 2 rows & 3 columns
• 3.Multi dimensional array :
datatype arrayname[size1][size2].....[sizen];
Input data into the Single dimensional array
Here we are iterating the array from 0 to 3 because the size of the array is 4.
Inside the loop we are displaying a message to the user to enter the values. All the
input values are stored in the corresponding array elements using scanf function.
for (i=0; i<4;i++)
{
cin>>num[i];
}
Printing data from Single dimensional array
Suppose, if we want to display the elements of the array then we can use the for
loop like this.
for (i=0; i<4;i++)
{
cout<<num[i];
}
Single Dimensional Array:
Example Program:
#include<stdio.h>
void main ( )
{
int a[5],i;
cout<<“enter 5 elements”; for
( i=0; i<5; i++)
cin>>a[i];
cout<<"elements of the array are";
for (i=0; i<5; i++)
cout<<a[i];
}
Output
The output is as follows −
enter 5 elements 10 20 30 40 50
elements of the array are : 10 20 30 40 50
Various ways to initialize a single dimensional array
In the above example, we have just declared the array and later we
initialized it with the values input by user. However you can also initialize the array
during declaration like this:
2D array – We can have multidimensional arrays like 2D and 3D array. However the
most popular and frequently used array is 2D – two dimensional array. We will see
how to declare, read and write data in 2D array along with various other features of
it.
Initialization of 2D Array
There are two ways to initialize a two Dimensional arrays during declaration.
int disp[2][4] = {
{10, 11, 12, 13},
{14, 15, 16, 17}
};
int disp[2][4] = { 10, 11, 12, 13, 14, 15, 16, 17};
Although both the above declarations are valid, the first method is more readable,
because you can visualize the rows and columns of 2d array in this method.
We know that, when we initialize a normal array (one dimensional array) during
declaration, we need not to specify the size of it. However that’s not the case with 2D
array, you must always specify the second dimension even if you are specifying
elements during the declaration.
Example:
/* Valid declaration*/
int abc[2][2] = {1, 2, 3 ,4 }
/* Valid declaration*/
int abc[][2] = {1, 2, 3 ,4 }
/* Invalid declaration – you must specify second dimension*/ int abc[][] = {1, 2, 3
,4 }
/* Invalid declaration – you must specify second dimension*/ int abc[2][] = {1, 2,
3 ,4 }
{
for(j=0;j<3;j++)
{
cin>>disp[i][j];
}
}
cout<<"Two Dimensional array elements:\n";
1 23
4 56
Output Matrix:
33
77
#include <iostream>
using namespace std;
int main(){
int i, j, size, temp;
int arr[25];
cout << "Enter the total no. of elements: ";
cin >> size;
Output:
Enter the total no. of elements: 5
Enter the elements of the array:
52714
Elements sorted in the ascending order are:
1
2
4
5
7
1.16 String
A string is a one-dimensional array of characters terminated by
a NULL ('\0') character. It can be read as a single entity, unlike other types of
arrays.
Strings in C++
A string is a collection of characters. There are two types of strings commonly
used in C++ :
Strings that are objects of string class (The Standard C++ Library String
Class)
C-strings (C-style Strings)
Strings can be defined in several ways in C++. Strings in C++ can be defined
either using the std::string class or the C-style character arrays.
Strings define objects that can be The null character terminates a character
represented as string streams. array of characters.
A string class provides numerous functions Character arrays offers few inbuilt
for manipulating strings. functions to manipulate strings.
These strings are stored as the plain old array of characters terminated by a null
character ‘\0’. They are the type of strings that C++ inherited from C language.
Syntax:
Output:
GeeksforGeeks
Using C-style strings
Using C-style string libraries functions such as strcpy(), strcmp(), and strcat() to
define strings. This method is more complex and not as widely used as the other
two, but it can be useful when dealing with legacy code or when you need
performance.
s1 = hai
s2 = hello
s3 = welcome
s4 = Programming in C++
Finding the length of a string without using string Library function:
#include <iostream>
using namespace std;
int main() {
char ch[20];
int i = 0;
cout << "Enter a string : ";
cin >> ch;
cout << "The entered string is : " << ch << "\n";
while (ch[i] != '\0’)
{
i++;
}
cout << "The length of the string " << ch << " is : " << i <<"\n";
return 0;
}
Output:
integer_variable = strlen(string);
Here string is a group of characters, strlen() function finds the length of the string
and finally integer value will be stored in the integer_variable.
The function strcpy() is used to copy one string into another string including
the NULL character (terminator char ‘\0’).
strcpy(string1, string2);
Where string1, string2 are two strings and the string2 is copied into string1. In this
case the copied string is available in string1 and both strings contain the same data.
If length of string1 is less than the length of string2, then the entire string2 value
will not be copied into string1.
For example, consider that the length of string1 is 20 and that of string2 is 30.
Then, only 20 characters from string2 will be copied into string1, the
remaining 10 characters will not be copied and will be truncated.
The function strcat() is used to concatenate two strings into one string.
The syntax of strcat() is
strcat(string1, string2);,
where string1, string2 are two different strings. Here string2 is concatenated
with string1, and finally the resultant concatenated string is stored in string1.
In strcat() operation, NULL character of string1 is overwritten by first
character of string2 and NULL character is added at the end of new string1 which is
created after strcat() operation.
The function strcmp() is used for comparison of two strings and it always returns
numeric data.
integer variable = strcmp (string1, string2);
where string1, string2 are two strings and variable is of the type integer.
The comparison of two strings is dependent on the alphabets and not on the
size of the strings.
#include <iostream>
#include<string.h>
int main()
char s1[50];
cout<<"Enter a string"<<endl;
cin>>s1;
cout<<"string Length=";
int len=strlen(s1);
cout<<len;
return 0;
Output:
Enter a string
Hello
string Length=5
Program for demonstration of stacat(), strcmp(), strcpy(), strlen()
#include <iostream>
#include <string.h>
using namespace std;
int main () {
char a[20], b[20], c[20];
int length;
cout << "Enter a string :";
cin >> a;
length = strlen(a);
cout << "The length of the string " << a <<" is "<< length <<"\n";
strcpy(b, a);
cout << "The copied string = " << b << "\n";
cout << "Enter the second string :";
cin >> c;
strcat(a, c);
cout << "The concatenated string = " << a << "\n";
int i=strcmp(b, c);
if(i == 0) {
cout << "The given two strings are equal" << "\n";
} else if(i > 0) {
cout << "The string " << b << " is higher than the string
" << c << "\n";
} else {
cout << "The string " << c << " is higher than the string "
<< b << "\n";
}
Enter the second string :Morning
}
The concatenated string =
Output :
GoodMorning
Enter a string :Good
The string Morning is higher than the
The length of the string Good is 4 string Good
These are the new types of strings that are introduced in C++ as string class defined
inside <string> header file. This provides many advantages over conventional C-style
strings such as dynamic size, member functions, etc.
Declaration and initialization of a string :
string str("GeeksforGeeks");
or
string str=”GeeksforGeeks”;
#include <iostream>
using namespace std;
int main()
{
return 0;
Output :
s = GeeksforGeeks
str = programming in c++
How to Take String Input in C++
String input means accepting a string from a user. In C++. We have different types of taking
input from the user which depend on the string. The most common way is to take input
with cin keyword with the extraction operator (>>) in C++. Methods to take a string as
input are:
cin
getline
1. Using Cin
The simplest way to take string input is to use the cin command along with the
stream extraction operator (>>).
Syntax:
cin>>s;
Example:
// C++ Program to demonstrate string input using cin
#include <iostream>
using namespace std;
int main()
{
string s;
cout<<"Enter String"<<endl;
cin>>s;
cout<<"String is: "<<s<<endl;
return 0;
}
Output:
Enter String
GeeksforGeeks
String is: GeeksforGeeks
The getline() function in C++ is used to read a string from an input stream. It is
declared in the <string> header file.
char ch[20];
cin.getline(ch, 20);
Here ch is an array of type char, cin.getline() is used to read a line of text from the
input stream and it is terminated as soon as either a new line character (\n) is
encountered or maximum size of characters are read.
By reading characters using getline(), one character in size is reserved
for null character '\0’.
Program :
#include <iostream>
using namespace std;
int main()
{
Output:
char ch[20];
Enter a string :
cout << "Enter a string : "<<endl;
welcome
cin.getline(ch,20);
The given text is..welcome
cout<<"The given text is.."<<ch<<endl;
return 0;
}
Program :
#include<iostream>
using namespace std;
int main()
{
string str1 = "apple";
string str2 = "banana";
if (str1==str2)
cout<<"Both Strings are equal";
else
cout<<"Both strings are not equal";
return 0; }
1.17C++ String Functions
C++ ome inbuilt functions which are used for string manipulation, such as the
strcpy() and strcat() functions for copying and concatenating strings. Some of
them are:
Function Description
pop_back() This function is used to pop the last character from the string
clear() This function is used to remove all the elements of the string.
This function compares at most the first num bytes of both passed
strncmp()
strings.
This function appends a copy of the source string to the end of the
strcat()
destination string
This function is used to search for a certain substring inside a string
find()
and returns the position of the first character of the substring.
This function is used to compare two strings and returns the result
compare()
in the form of an integer.
Explanation:
1. String Length – length() or size()
We can find the length of the string (number of characters) using either length()
or size() function of the std::string class.
Syntax
string_object.size()
or
string_object.length()
Parameters
This function does not take any parameter.
Return Value
This function returns the number of characters in the string object.
Example
std::string text = "geeksforGeeks";
int length = text.length();
//or
int length = text.size();
It will return the length of the string text which is 13.
2. Accessing Characters – at()
Generally, we can access the character of a string using the [] array subscript
operator and indexing. But std::string also has a function named at() which
can be used to access the characters of the string.
Syntax
string_object.at(index);
Parameters
index: It represents the position of the character in the string.
Return Value
This function returns the character present at the index.
Example
std::string str = "GEEKSFORGEEKS";
std::cout << str.at(3);
The std::cout will print K on the console as it is the character present at index 3.
3. Concatenating Strings – append() or + Operator
We can concatenate string in C++ using two methods:
(i) + Operator
The + operator is overloaded in the std::string class to perform string
concatenation.
Syntax
string_object1 + string_object2
Example
std::string firstName = "Geeks";
std::string lastName = "forGeeks";
std::string fullName = firstName + " " + lastName;
+ operator is used to concatenate two strings. The string fullName will be
“GeeksforGeeks”.
(ii). append()
The append() function is another member function to concatenate two strings.
Syntax
string_object1.append(string2)
Parameters
string2: This function takes the string to be appended as a parameter. It can
be both C or C++ Style string.
Return Value
Reference to the final string.
std::string base = "Hey! Geeks";
base.append(" Welcome to GeeksforGeeks!"); // Append a string
The append() function adds one string to the end of another.
4. String Comparison – compare() or == Operator
Just like the concatenation, we can do the string comparison using two methods:
(i). == Operator
The equality operator can be used to compare the two strings as it is overloaded for
this operation in the std::string class.
Syntax
string_object1 == string_object2
This will return true if both the strings are equal, otherwise returns false.
Example
std::string str1 = "apple";
std::string str2 = "banana";
if (str1 == str2) {
std::cout << "Strings are equal";
}
else {
std::cout << "Strings are not equal";
}
Here, “Strings are not equal” will be printed as the == operator will return false.
(ii). compare()
The compare() function is a member function of std::string class which can be
used to compare two strings.
Syntax
str1.compare(str2);
Parameters
str2: It is the string to be compared. It can be both C or C++ style string.
Return Value
If the strings are equal, return zero.
If str1 is greater than str2, return value >0
If str2 is greater than str1, return value <0
Example
string str1 = "Geeks";
string str2: = "Geeksfor";
int result = str1.compare(str2);
The result will contain a value less than zero as str2 is greater than str1.
We can also compare the substring of str2 using the compare function():
str1.compare(position, length, str2);
where,
position: position of the first character substring.
length: length of the substring.
str2: String object to be compared.
5. Searching – find()
We can use the find() function of the std::string class to check whether a given
character or a substring is present in the string or a part of string.
Syntax of find()
str1.find(var);
Parameters
var: It can be a C style string, C++ style string, or a character that is to be
searched in the string.
Return Value
It returns the pointer to the first occurrence of the character or a substring
in the string.
Example
std::string text = "C++ Programming";
int position = text.find("Programming"); // Find the position of a substring
The position variable will contain 4 which is the start of the first occurrence of the
string “Programming” in string text.
6. Generate Substring – substr()
We can use the substr() function to generate a part of the string as a new
string object. It is a member function of the std::string class.
Syntax of substr() in C
str1.substr(start, end);
Parameters
start: Starting position of the substring to be generated.
end: Ending of the substring to be generated.
Return Type
It returns the newly created string object.
Example
std::string text = "Hello, World!";
std::string sub = text.substr(7, 5); // Extract "World"
In the above example. the sub string will contain the “World”.
Modifying Strings
The following function allows us to modify the current string.
1. insert()
The insert() function not only allows us to add a string but also allows us to add it
at the specified position. It is also a member function of the std::string class.
Syntax
str1.insert(index, str2);
Parameters
str2: string to be inserted.
index: position of where to insert the new string
Return Type
Reference to the str1.
Example
string text = "I have a cat.";
text.insert(9, " black"); // Insert " black" at position 9
2. replace()
The replace() function replaces the part of the string with the given other string.
Unlike insert, the characters in the part where the new string is to be inserted are
removed.
Syntax
str1.replace(index, size, str2);
Parameters
index: Index of where to start replacing the new string.
size: length of the part of the string that is to be replaced.
str2: new string that is to be inserted.
Return Type
Reference to the str1.
Example
std::string text = "I like dogs.";
text.replace(7, 4, "cats"); // Replace "dogs" with "cats"
3. erase()
The erase() function is a member function of std::string class that is used to remove
a character or a part of the string.
Syntax
str1.erase(start, end);
Parameters
start: Starting position.
end: Ending position.
Return Type
Reference to the str1.
Example
string text = "This is an example.";
text.erase(5, 3); // Erase "is “
Example of String Functions in C++
The below code demonstrate the use of the above specified string functions:
// C++ Code to demostrate various functions available in String class
#include <iostream>
#include <string>
using namespace std;
int main()
{
// Creating and initializing strings
string greeting = "Hello, World!";
cout << greeting << endl;
string name;
// Input from the user
cout << "Enter your name: ";
cin >> name;
cout << name << endl;
// String length
int len = name.length();
cout <<"Length of the string"<<len<< endl;
// Accessing characters
char firstChar = greeting[0];
char secondChar = greeting.at(1);
cout << firstChar << " " << secondChar << endl;
// Appending and concatenating strings
string firstName = "Geek";
string lastName = "Geeks";
string fullName = firstName + " " + lastName;
cout << fullName << endl;
string base = "Hello";
cout << base << endl;
base.append(" World!");
cout << base << endl;
// String comparison
string str1 = "apple";
string str2 = "banana";
if (str1 == str2) {
cout << "Strings are equal" << endl;
}
else {
cout << "Strings are not equal" << endl;
}
int result = str1.compare(str2);
if (result == 0) {
cout << "Strings are equal" << endl;
}
else if (result < 0) {
cout << "str1 comes before str2" << endl;
}
else {
cout << "str1 comes after str2" << endl;
}
// Substrings
string text = "Hello, World!";
cout << text << endl;
string sub = text.substr(7, 5);
cout << sub << endl;
// Searching
string searchIn = "C++ Programming";
size_t position = searchIn.find("Programming");
if (position != string::npos) {
cout << "Found at position " << position << endl;
}
else { Output:
modify.replace(7, 4, "cats"); He
} I like cats.
C++
1.18 Array Of Strings :
The size of the first index (rows) determines the number of strings and the size
of the second index (columns) determines maximum length of each string.
char array_name[row_size][column_size];
In the above statement str is an array name which refers 4 strings and each
string of maximum length is 7.
The memory allocation to the array str is looks like as:
F i r s t \0
S e c o n d \0
T h i r d \0
F o u r \0
It is very easy to access an individual string, by just specifying the first index
as str[0] we can access the first string.
Program :
#include<iostream>
using namespace std;
int main()
{
char str[4][10]={"India","China","England","Russia"};
cout<<"The First Nation is .."<<str[0]<<endl;
cout<<"The Last nation is.."<<str[3];
return 0;
}
Output:
{
cout<<names[i]<<"\n";
return 0;
}
Output:
Enter any 5 names : kumar mani yaswanth akhil sundar
kumar
mani
sundar
Yaswanth
10. Assignment Questions
Write the code that Jaya used to craft the tool that calculates
the cube of each element in an array.
Write programs for the given problems
S.No. K-Level COs
Adding new data and functions is not easy. Adding new data and function is easy.
4.What are types of Programming Languages ?
• Preprocessing
• Assembling
• Compiling
• Linking
6.Define Keywords :
A variable whose declaration preceded along with const keyword, these variables
are called as read only variables , we can’t alter the value of that constant variables
Syntax Error
Run time Error
Linker error
Logical Error
Semantic Error
User defined
x = (a>b) ? a : b
17.What are the Types of Operators?
while loop
do…while loop
Condition Evaluation The loop body would The loop body would
be executed, only if be executed at least
the given condition is once, even if the
true given condition is
evaluated as false
if (result == num)
cout << num << " is an Armstrong number.";
else
cout << num << " is not an Armstrong number.";
return 0;
}
Output:
Enter a three-digit integer: 153
153 is an Armstrong number.
Basis for
break continue
Comparison
Task It terminates the It terminates only
execution of the current
remaining iteration iteration of the
of the loop. loop.
Control after 'break' resumes the 'continue' resumes
break/continue control of the the control of the
program to the end program to the
of loop enclosing next iteration of
that 'break'. that loop enclosing
'continue'.
Causes It causes early It causes early
termination of loop. execution of the
next iteration.
Continuation 'break' stops the 'continue' do not
continuation of stops the
loop. continuation of
loop, it only stops
the current
iteration.
Other uses 'break' can be used 'continue' can not
with 'switch', be executed with
'label'. 'switch' and 'labels'.
30.What do you mean by an Array? List Advantages and
disadvantages of Array?
• Array is a set of similar data type.
• Arrays objects store multiple variables with the same type.
• It can hold primitive types and object references.
•Arrays are always fixed
Advantages:
• We can put in place other data structures like stacks, queues, linked lists, trees,
graphs, etc. in Array.
• Arrays can sort multiple elements at a time.
•We can access an element of Array by using an index.
Disadvantages:
• We have to declare Size of an array in advance. However, we may not know
what size we need at the time of array declaration.
• The array is static structure. It means array size is always fixed, so we cannot
increase or decrease memory allocation
❖ https://swayam.gov.in
❖ https://www.coursera.org
❖ https://www.udemy.com
❖ https://www.sololearn.com
❖ https://www.tutorialspoint.com/cplusplus
❖ https://www.geeksforgeeks.org/courses/cpp-programming-basic-
to-advanced
❖ https://www.geeksforgeeks.org/c-plus-plus
14. Real Time Applications
15. Content beyond syllabus
Namespace in C++
In C++, there are two ways of accessing namespace variables and functions.
Defining a Namespace:
A namespace definition begins with the keyword namespace followed by the
namespace name as follows:
namespace namespace_name
{
// code declarations i.e. variable (int a;)
method (void add();)
classes ( class student{};)
}
It is to be noted that, there is no semicolon (;) after the closing brace.
To call the namespace-enabled version of either function or variable,
prepend the namespace name as follows:
Namespace name: :code; // code could be variable , function or class.
Program:
#include <iostream>
using namespace std;
// first name space
namespace first_space
{
void func()
{
cout << "Inside first_space" << endl;
}
// second name space
namespace second_space
{
void func()
{
cout << "Inside second_space" << endl;
} } }
using namespace first_space::second_space;
int main () Output:
{
Inside second_space
// This calls function from second name space.
func();
return 0;
}
//C++ program to demonstrate accessing of variables
// in normal way, i.e., using "::“
#include <iostream>
using namespace std;
namespace geek
{
int rel = 300;
} Output :
300
int main()
{
// variable ‘rel’ accessed
// using scope resolution operator
cout << geek::rel << "\n"; // prints 300
return 0;
}
C++ program to demonstrate accessing of variables
// in normal way, i.e., using "using" directive
#include <iostream>
using namespace std;
namespace geek
{
int rel = 300;
}
// use of ‘using’ directive
using namespace geek;
int main()
{
// variable ‘rel’ accessed
// without using scope resolution variable
cout << rel << "\n"; //prints 300
return 0;
}
16. Assessment Schedule
Text Books:
1. Herbert Schildt, “The Complete Reference C++”, 4th edition, MH, 2015.
2. E Balagurusamy,” Object Oriented Programming with C++”, 4th Edition, Tata
McGraw- Hill Education, 2008.
Reference Books:
By building this project, you will comprehend the basics of the input and
output course. Furthermore, this C++ project structure will help you in knowing
about the system of file management. The program designed by you will be ready
to accumulate all the students’ data and information correctly. This data can be any
information related to the student, their personal information, academic records,
roll number, etc. This project will teach you how to tackle wrong inputs. ( K1, CO1)
Open an account
Deposit
Withdraw
This project will let you understand the fundamentals of banking apps. In a
nutshell, you can say that this primary C++ project is going to familiarize you with
data adjustment, how to add, modify or delete any filed record ( K2, CO1)
3. Bookshop Management System Using C++
To build an application that will let its customers add and display
books. Furthermore, it will help the customers to change their books by
implementing modifications to them or adding or deleting pages. Create an
application that will be user-friendly and effortless to access and use. It also lets
users check and buy their favourite books anytime, anywhere with one click. (
K3,CO1)
5.Digital Calculator
This project is particularly GUI-driven, making it easy to execute.
This project will be a menu-driven program in which the outputs will be given by
the user. It assists to strengthen some of the fundamental concepts of C++,
particularly relating data types and decision-making statements.
The project requires validation for the inputs so that the calculation only takes
place if the inserted data is numerical by nature. (K5, CO1)
Thank
you
Disclaimer:
This document is confidential and intended solely for the educational purpose of RMK Group of
Educational Institutions. If you have received this document through email in error, please notify the
system manager. This document contains proprietary information and is intended only to the
respective group / learning community as intended. If you are not the addressee you should not
disseminate, distribute or copy through e-mail. Please notify the sender immediately by e-mail if you
have received this document by mistake and delete this document from your system. If you are not
the intended recipient you are notified that disclosing, copying, distributing or taking any action in
reliance on the contentsof this information is strictly prohibited.