CPP Lab Manual
CPP Lab Manual
CPP Lab Manual
LABORATORY MANUAL
Semester-III
INDEX
4 Syllabus vii
6 List of Experiments x
1. Identify, understand, formulate and analyze complex engineering problems in the field of
Network system, Database management, Web communication, Computer programming
and software development.
2. Plan, design, develop and manage software in the field of artificial intelligence , data
mining, network management and security, cloud based services and Internet of Things
applications through use of secure, reliable and cost effective state of art IT tools
efficiently.
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
Course Objectives
3. Understand the multithreaded programs in Java and C++ and implement solution for
concurrency as solution
4. Apply knowledge use of exception handling and garbage collection in C++ and JAVA
Course Outcomes
After completing this course, the learners should be able to:
3. Understand the multithreaded programs in Java and C++ and implement solution for
concurrency as solution
4. Apply knowledge use of exception handling and garbage collection in C++ and JAVA
LIST OF EXPERIMENT'S
Expt. Page No. COs
Name of the Experiment
No.
1. Implementation of basic data types in C++ 1 CO1
• Write a program to find swapping without using
third variable using C++
• Write a program to find sum and avg of three
numbers using C++
values in C++
b. Implementation of parameterized constructor to
syllabus)
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
CO1 2 1 1 1 1 1 1
CO2 2 1 1 1 1 1 1
CO3 2 1 1 1 1 1 1
CO4 2 1 1 1 1 1 1
CO5 2 1 1 1 1 1
CO6 2 1 1 1 1 1 1
PSO1 PSO2
CO1 2 1
CO2 2 1
CO3 2 1
CO4 2 1
CO5 2 1
CO6 2 1
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 1
The memory size of basic data types may change according to 32 or 64 bit operating
system.
All variables use data-type during declaration to restrict the type of data to be
stored. Therefore, we can say that data types are used to tell the variables the type of data
it can store. Whenever a variable is defined in C++, the compiler allocates some memory
for that variable based on the data-type with which it is declared. Every data type requires
a different amount of memory.
Data types in C++ are mainly divided into three types:
Primitive Data Types: These data types are built-in or predefined data types and can be
used directly by the user to declare variables.
example: int, char , float, bool etc. Primitive data types available
in C++ are:
• Integer
• Character
• Boolean
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
• Floating Point
• Double Floating Point
• Valueless or Void
• Wide Character
Derived Data Types: The data-types that are derived from the primitive or built-in
datatypes are referred to as Derived Data Types. These can be of four types namely:
• Function
• Array
• Pointer
• Reference
Abstract or User-Defined data types: These data types are defined by user itself. Like,
defining a class in C++ or a structure. C++ provides the following user-defined datatypes:
• Class
• Structure
• Union
• Enumeration
• Typedef defined Datatype
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
Datatype Modifiers
As the name implies, datatype modifiers are used with the built-in data types to modify the
length of data that a particular data type can hold.
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
PROGRAM CODE-
1.Write a program to find swapping without using third variable using C++
#include <iostream>
using namespace std;
int main()
{
int a=5, b=10;
cout<<"Before swap a = "<<a<<" b =
"<<b<<endl; a=a+b; b=a-b; a=a-
b;
cout<<"After swap a = "<<a<<" b = "<<b<<endl;
return 0;
}
OUTPUT-
PROGRAM CODE-
2.Write a program to find sum and average of two numbers using C++
#include <iostream>
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
OUTPUT :
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
CONCLUSION:
Successfully Implemented Basic data types in C++ and implements a Two program. one is
swap a two values without using Third variable. second one is find a sum and average of
two numbers.
REFERENCES :
1. https://www.programiz.com/cpp-programming/examples/swapping
2. https://www.youtube.com/watch?v=HrAbV_MyWXM
3. https://www.youtube.com/watch?v=9dMJOTT9TYc
4. https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 2
In C++ programming, if statement is used to test the condition. There are various types of
if statements in C++.
• if statement
• if-else statement
• nested if statement
• if-else-if ladder
//code to be executed
}
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
PROGRAM CODE-
1.To find fibonacci series using for loop.
int n, t1 = 0, t2 = 1, nextTerm
=;
cout <<"\nEnter the number of terms: ";
cin >> n;
cout <<"Fibonacci Series: ";
for (int i = 1; i <= n; ++i)
{
if(i == 1)
{
cout << t1 <<", ";
continue;
}
if(i == 2)
{
cout << t2 <<",
";
continue;
}
nextTerm = t1+ t2;
t1 = t2;
t2 = nextTerm;
cout << nextTerm <<", ";
} return 0;
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
OUTPUT
PROGRAM CODE-
2.To find even or odd number using if else
#include <iostream>
using namespace std;
int
main()
{
int n;
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
OUTPUT
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
CONCLUSION :
Successfully Implemented Loops in C++ and implements a Two program one is fibonacci
series using for loop. second one is find even or odd number using if else.
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
REFERENCES :
1. https://www.javatpoint.com/cpp-for-loop
2. https://www.javatpoint.com/cpp-while-loop
3. https://www.w3schools.com/cpp/cpp_for_loop.asp
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 3
The expression is evaluated once and compared with the values of each case label.
• If there is a match, the corresponding code after the matching label is executed.
For example, if the value of the variable is equal to constant2, the code after
case constant2: is executed until the break statementis encountered. If
there is no match, the code after default: is executed. switch(expression){
case value1:
//code to be executed;
break;
case
value2:
//code to be executed;
break;
......
default:
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
PROGRAM CODE-
1. Write a program to perform arithmetic operation using switch case
#include <iostream>
using namespace std;
int main()
{
int a,b,result;
cout<<"* Enter two values whose sum is 10 or 50 or 100 *";
cout<<"\n\nEnter a value for A = ";
cin >> a;
cout<<"Enter a value for B = ";
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
cin >> b;
result = a+b;
switch(result){ case 10 :
cout<<"The value of A + B is : "<<result; break;
case 50 :
cout<<"The value of A + B is : "<<result; break;
case 100 :
cout<<"The value of A + B is : "<<result; break;
default :
cout <<"The Given Choice is not Match"; break;
} return
0; }
OUTPUT
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
PROGRAM CODE-
2. Write a program to print 1 to 5 number using while loop
#include
<iostream> using
namespace std;
int main() {
cout<<"\nThe value is 1 to 5 :\n";
int i = 1;
while( i <= 5){
cout<<"\t"<<i<<"\n";
++i; } return 0;
}
OUTPUT
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
CONCLUSION :
Successfully Implemented Loops in C++ and implements a Two program one is to
perform arithmetic operation using switch case. and second one is to print 1 to 5
number using while loop.
EXPERIMENT NO- 4
AIM: Write a program for arithmetic operation using function overloading in C++
RESOURCES REQUIRED: Turbo C++, Pentium IV, Printer
THEORY: Types of overloading in C++ are:
• Function overloading
• Operator overloading
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
PROGRAM CODE-
#include <iostream>
using namespace std;
class Cal { public:
static int add(int a,int b)
{
return a + b;
}
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
return 0;
OUTPUT :-
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
5.Data members and member functions of a class are private by.default. True or False?
REFERENCES :
1. https://www.programiz.com/cpp-programming/function-overloading
2. https://www.javatpoint.com/cpp-overloading
3. https://www.youtube.com/watch?v=dh0mKAPFzlQ
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 5
There are two ways to pass value or data to function in C language: call by value and call by
reference. Original value is not modified in call by value but it is modified in call by
reference.
Let's understand call by value and call by reference in C++ language one by one.
In call by value, value being passed to the function is locally stored by the function
parameter in stack memory location. If you change the value of function parameter, it is
changed for the current function only. It will not change the value of variable inside the
caller method such as main().
Let's try to understand the concept of call by value in C++ language by the example given
below:
#include <iostream>
using namespace std;
void change(int data);
int main()
{
int data = 3;
change(data);
cout <<"Value of the data is: "<< data<< endl;
return 0;
}
void change(int data)
{
data = 5;
}
OUTPUT:
Value of the data is: 3
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
OUTPUT:
Value of x is: 100
Value of y is: 500
PROGRAM CODE-
1.Call By Value program in C++.
#include<iostream> using
namespace std; void
change(int data); int
main()
{
int data = 10;
change(data);
cout <<"\nCall By Value Program :"<<endl;
cout <<"\nValue of the data is: "<< data<< endl; return 0; }
void change(int data)
{ data
= 5;
}
OUTPUT :
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
OUTPUT :-
REFERENCES :
1. www.codewithharry.com › cpp-tutorials-in-hindi-16
2. https://www.scaler.com/topics/difference-between-call-by-value-and-call-by-reference/
3. https://www.javatpoint.com/call-by-value-and-call-by-reference-in-cpp
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 6
AIM:A ) write a program to concatenate a list and store in another list in prolog.
B) Write a program to calculate length of list
The list is a simple data structure that is widely used in non-numeric programming. List
consists of any number of items, for example, red, green, blue, white, dark. It will be
represented as, [red, green, blue, white, dark]. The list of elements will be enclosed with
square brackets. A list can be either empty or non-empty. In the first case, the list is simply
written as a Prolog atom, []. In the second case, the list consists of two things as given
below −
• The first item, called the head of the list;
• The remaining part of the list, called the tail.
Suppose we have a list like: [red, green, blue, white, dark]. Here the head is red and tail is
[green, blue, white, dark]. So the tail is another list.
Now, let us consider we have a list, L = [a, b, c]. If we write Tail = [b, c] then we can also
write the list L as L = [ a | Tail]. Here the vertical bar (|) separates the head and tail parts.
So the following list representations are also valid −
• [a, b, c] = [x | [b, c] ]
• [a, b, c] = [a, b | [c] ]
• [a, b, c] = [a, b, c | [ ] ]
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
A data structure that is either empty or consists of two parts − a head and a tail. The tail
itself has to be a list.
Length Calculation
This is used to find the length of list L. We will define one predicate to do this task. Suppose
the predicate name is list_length(L,N). This takes L and N as input argument. This will count
the elements in a list L and instantiate N to their number. As was the case with our previous
relations involving lists, it is useful to consider two cases − If list is empty, then length is
0.
• If the list is not empty, then L = [Head|Tail], then its length is 1 + length of Tail.
Concatenation
Concatenation of two lists means adding the list items of the second list after the first one.
So if two lists are [a,b,c] and [1,2], then the final list will be [a,b,c,1,2]. So to do this task we
will create one predicate called list_concat(), that will take first list L1, second list L2, and
the L3 as resultant list. There are two observations here.
• If the first list is empty, and second list is L, then the resultant list will be L.
• If the first list is not empty, then write this as [Head|Tail], concatenate Tail with L2
recursively, and store into new list in the form, [Head|New List].
CONCLUSION :-
Successfully Run a Program Concatenate List and Calculate length of List.
REFERENCES :
1. https://swish.swi-prolog.org/
2. https://www.tutorialspoint.com/execute_prolog_online.php
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
3. https://www.tutorialspoint.com/prolog/prolog_introduction.htm
4. https://www.javatpoint.com/prolog
EXPERIMENT NO- 7
In Prolog, operators are used as predicates but here operators are functions and these
operators return a numerical value. Arithmetic expressions can include variables, numbers,
operators, and arithmetic functions. These will be written in parentheses with their
arguments. Arithmetic operators are used to perform arithmetic operations. There are few
different types of arithmetic operators as follows –
Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
** Power
// Integer Division
mod Modulus
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
Comparison operators are used to compare two equations or states. Following are
different comparison operators –
Operator Meaning
X>Y X is greater than Y
X<Y X is less than Y
X >= Y X is greater than or equal to Y
X =< Y X is less than or equal to Y
X =:= Y the X and Y values are equal
X =\= Y the X and Y values are not equal
CONCLUSION:-
Successfully Run the Program to perform arithmetic Operation.
REFERENCES:
1. https://www.tutorialspoint.com/prolog/prolog_operators.htm
2. https://www.javatpoint.com/arithmetic-in-prolog
3. http://projog.org/prolog-arithmetic.html
4. https://www.youtube.com/watch?v=AXuhIFciI0c
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 8
AIM: write a program to read and display employee details using class and objects.
RESOURCES REQUIRED: Turbo C++/Java , Pentium IV, Printer
THEORY:
C++ is an object-oriented language, program is designed using objects and classes in C++.
C++ Object
In C++, Object is a real world entity, for example, chair, car, pen, mobile, laptop etc.
In other words, object is an entity that has state and behavior. Here, state means data and
behavior means functionality.
Object is a runtime entity, it is created at runtime.
Object is an instance of a class. All the members of the class can be accessed through
object.
Let's see an example to create object of student class using s1 as the reference variable.
Student s1; //creating an object of Student
C++, class is a group of similar objects. It is a template from which objects are created. It
can have fields, methods, constructors etc.
Let's see an example of C++ class that has three fields only.
class Student
{ public:
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
PROGRAME CODE-
#include <iostream>
using namespace std;
class employee
{
int emp_number;
char emp_name[20];
char emp_addr[30];
float emp_sal;
char emp_dep[30];
public:
void get_emp_details();
float find_net_salary(float basic);
void show_emp_details();
};
void employee :: get_emp_details()
{
cout<<"\n Enter employee number : ";
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
cin>>emp_number;
cout<<"\n Enter employee name : ";
cin>>emp_name;
cout<<"\n Enter employee Address : ";
cin>>emp_addr;
cout<<"\n Enter employee Salary: ";
cin>>emp_sal;
cout<<"\n Enter employee Department Name : ";
cin>>emp_dep;
}
void employee :: show_emp_details()
{
cout<<"\n\n** Details of Employee **";
cout<<"\nEmployee Name : "<<emp_name;
cout<<"\nEmployee number : "<<emp_number;
cout<<"\nBasic salary : "<<emp_sal;
cout<<"\nEmployee Department : "<<emp_dep;
cout<<"\nEmployee Address : "<<emp_addr;
cout<<"\n-------------------------------\n\n";
}
int main()
{
employee emp;
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
emp.get_emp_details();
emp.show_emp_details();
return 0;
}
OUTPUT : -
CONCLUSION-
Successfully Write a Programmed to read and display employee details using class
and objects.
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
REFERENCES :
1. https://www.youtube.com/watch?v=wlXCFNuVjBY
2. https://www.programiz.com/cpp-programming/object-class
3. https://www.javatpoint.com/cpp-object-and-class
4. https://www.includehelp.com/cpp-programs/cpp-programs-classes-and-objects-solved-
programs.aspx
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 9
{
a = 15;
b = 25;
res = a+b;
x = 10;
y = 20;
res1 = x*y;
}
};
int main()
{ construct c;
cout <<"\n* Default Constructor *"<<endl;
cout <<"a: "<< c.a << endl
<<"b: "<< c.b <<endl
<<"Addition : "<< c.res;
OUTPUT:
PROGRAM CODE :
#include <iostream>
void display (){ cout<<"Roll Number : "<<id<<", Name : "<<name<<", Marks : "<<salary<<endl; }
};
int main(void) {
cout<<"\n*: Student Details :*"<<endl<<endl;
Professor p1=Professor(101, "Sammer Ansari ", 90);
Professor p2=Professor(102, "Rohon Moriya ", 88);
OUTPUT :
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
3. https://www.javatpoint.com/cpp-constructor
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 10
(2) Write a program to find addition, subtraction, multiplication, division of numbers in Haskell.
(3) Write a program to display series of number 1 to 10.
That’s called referential transparency and not only does it allow the compiler to reason about
theprogram’s behavior , but it also allows you to easily deduce (and even prove) that a function
is correct and then build more complex functions by gluing simple functions together.
Haskell is lazy. That means that unless specifically told otherwise, Haskell won’t execute functions
and calculate things until it’s really forced to show you a result. That goes well with referential
transparency and it allows you to think of programs as a series of transformations on data. It also
allows cool things such as infinite data structures. Say you
have an immutable list of numbers xs = [1,2,3,4,5,6,7,8] and a function doubleMe which
multiplies every element by 2 andthen returns a new list. If we wanted to multiply our list by 8 in
an imperative language and did doubleMe(doubleMe(doubleMe(xs))), it would probably pass
through the list once and make a copy and then return it. Then it would pass through the list
another two times and return the result. In a lazy language, calling doubleMe on a list without
forcing it to show you the result ends up in the program sort of telling you “Yeah yeah, I’ll do it
later!”. But once you want to see the result, the first doubleMe tells the second one it wants the
result, now! The second one saysthat to the third one and the third one reluctantly gives back a
doubled 1, which is a 2. The second one receives that andgives back 4 to the first one. The first
one sees that and tells you the first element is 8. So it only does one pass throughthe list and only
when you really need it. That way when you
want something from a lazy language you can just take some initial data and efficiently transform
and mend it so it resembles what you want at the end.
Haskell is statically typed. When you compile your program, the compiler knows which piece of
code is a number, which is a string andso on. That means that a lot of possible errors are caught
at compile time. If you try to add together a number and a string, the compiler will whine at you.
Haskell uses a very good type system that has type inference. That means that you don’t have to
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
explicitly label every piece of code with a type because the type system can intelligently figure
out a lot about it. If you say a = 5 + 4, you don’t have to tell Haskell that a is a number, it can
figure that out by itself. Type inference also allows your code to be more general. If a function
you make takes two parameters and adds them together and you don’t explicitly state their type,
the function will work on any two parameters that act like
numbers.
Haskell is elegant and concise. Because it uses a lot of high level concepts, Haskell programs are
usually Lshorter than their imperative equivalents. And shorter programs are easier to maintain
than longer ones and have less bugs.
Haskell was made by some really smart guys (with PhDs). Work on Haskell began in 1987 when a
committee of researchers got together to design a kick-asslanguage. In 2003 the Haskell Report
was published, which defines a stable version of the language.
REFERENCES :
1. https://www.haskell.org/
2. https://www.tutorialspoint.com/haskell/index.htm
3. https://www.youtube.com/watch?v=Qa8IfEeBJqk
4. https://www.geeksforgeeks.org/what-is-haskell-programming-language/
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
EXPERIMENT NO- 11
● The Python interpreter works by loading a source file or reading a line typed at the
keyboard, parsing it into an abstract syntax tree, compiling the tree into bytecode, and
executing the bytecode. We will concentrate mainly on how the bytecode is executed,
such as how inheritance and environments are implemented.
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
REFERENCES :
Mahatma Gandhi Mission’s
College of Engineering and Technology
(Affiliated to University of Mumbai and Approved by, AICTE, New Delhi.)
Plot No. 1, 2, Sion - Panvel Expressway, Sector 18, Kamothe, Navi Mumbai,
Maharashtra 410209 Website : www.mgmmumbai.ac.in
1. https://www.ijcaonline.org/archives/volume177/number31/thaker-2020-ijca-
919775.pdf
2 https://www.geeksforgeeks.org/programming-paradigms-in-python/
3. https://opensource.com/article/19/10/python-programming-paradigms
4. https://www.educative.io/courses/learn-functional-programming-in-python/N732Z6APX46