C++ Industrial Training
C++ Industrial Training
C++
Name – Rutuja Babasaheb Salunkhe
Branch – Information Technology
PRN No. – 2030331246057
Seminar Guide – Ms. Ekta Meshram
Content
Introduction
History of C++
What is C++?
Uses of C++
Advantages of C++
Disadvantages of C++
Standard Libraries
C++ data types
C++ variable scope
Operators
Functions
Array
Inheritance in C++
Pointer
String
File handling in C++
Introduction
C++ is a popular programming language. It was created by Bjarne Stroustrup at Bell Labs circa, and released in
1980.
It is used for:
• Game development
• Software development,
• Mathematics
• Web browsers.
What can C++ do?
• C++ can be used for game development.
• C++ can be used for Machine Learning Tools such as TensorFlow.
• C++ can be used for AR/VR Applications such as developing augmented reality and virtual reality
applications. In fact, many of these applications run on Unreal Engine, which is built using C++.
Uses of C++ Language
Output :
30
Operators
Arithmetic operators
Relational operators
Logical operators
Bitwise operators
Assignment operators
Arithmetic Operators
#include<iostream> c=a- -;
void main() cout<<“decrement of a by one”
{ <<c;
int a , b , c; return 0; }
cout<<“enter the value for a and b”;
cin>>a>>b;
c= a+b;
cout<<c;
c=a-b;
cout<<c;
c=a*b;
cout<<c;
c=a/b;
cout<<c;
c=a++;
cout<<“ increment of a by one”<<c;
Relational Operators
#include<iostream>
using namespace std; if ( a>=b)
void main() cout<<“a is greater than or equal to
b”;}
{ if(a==b)
int a , b , ; { cout<<“ a is equal to b”;}
a=10;b=13; if( a!=b)
if (a<b) { cout<<“ a is not equal to b”;}
{ cout<<“ a is less than b”;}
if ( a>b) return 0;}
{ cout<< “ a is greater than b”;}
if (a<=b)
{ cout<<“ a is less than or equal to b”;}
Logical Operators
#include<iostream> a=0;
using namespace std; b=10;
void main() if(a&&b)
{ { cout<<"condition is true"; }
int a,b; else
a=12; cout<<"condition is not true“;
b=10; if(!(a&&b))
if(a&&b) { cout<<"condition is true"; }
{ cout<<"condition is true"; } return 0;}
if(alb)
{ cout<<"condition is true"; }
Bitwise Operator
------------ -
A&B= 0000 1100
A|B = 0011 1101
A^B = 0011 0001
~A = 1100 0011
Assignment Operator
int x = 25;
x = 50 ;
Assignment Operator
Functions
Function is a set of statements to perform some task.
Every C++ program has at least one function, which
is main(), and all the most trivial programs can define
additional functions.
Syntax of Function
return-type function-name (parameters)
{
//function – body
}
Declaring , Defining and Calling Function
#include <iostream>
int sum (int x, int y); //declaring function
int main()
{int a = 10;
int b = 20;
int c = sum (a, b); //calling function
cout << c;
}
int sum (int x, int y) //defining function
{
return (x+y);
}
Output = 30
Calling a Function
Call by Value
Call by Reference
Arrays
Array is defined as a set of homogeneous data items. An Array is a
group of elements that share a common name that are differentiated
from one another by their positions within the array.
It is a data structure which allows a collective name to be given to a
group of elements which all have the same type.
Syntax
datatype arrayname[array size];
0 1 2 3 4
balance 1000.0 2.0 3.4 7.0 50.0
Inheritance in C++
The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance
is one of the most important feature of Object Oriented Programming.
Sub Class: The class that inherits properties from another class is called Sub class or Derived Class.
Super Class: The class whose properties are inherited by sub class is called Base Class or Super class.
Pointers
Pointer is a user defined data type which creates special types of variables which can
hold the address of primitive data type like char, int, float, double or user defined
data type like function, pointer etc. or derived data type like array, structure, union,
enum.
Syntax
datatype "var-name;
Using Pointers in C+
+
There are few important operations, which we will do with thepointers
very frequently.
(a) we define a pointer variables
(b) assign the address of a variable to a pointer and
(c) 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.
C++ Strings
The following declaration and initialization create a string
consisting of the word “ Hello”. To hold the null character at
the end of the array , the size of the character array containing
the string is one more than the number of characters in the
word “ Hello”.
OUTPUT
Greeting message: Hello
File Handling in C++
File Handling concept in C++ language is used for store a data
permanently in computer. Using file handling we can store our data in
Secondary memory (Hard disk).
Datatype Description
ofstream This is used to create a file and
write data on files
ifstream This is used to read data from
files
fstream This is used to both read and
write data from / to files
How to Achieve File Handling