Академический Документы
Профессиональный Документы
Культура Документы
CONTENTS
To be the fountain head of novel ideas & innovations in science & technology & persist to be
a foundation of pride for all Indians.
To provide value based broad Engineering, Technology and Science where education in
students is urged to develop their professional skills.
To inculcate dedication, hard work, sincerity, integrity and ethics in building up overall
professional personality of our student and faculty.
Attaining global recognition in computer science and engineering education, research and
training to meet the growing needs of the industry and society.
Provide quality undergraduate and postgraduate education, in both the theoretical and applied
foundations of computer science, and train students to effectively apply this education to solve
real-world problems, thus amplifying their potential for lifelong high-quality careers.
1. To prepare students for successful careers in software industry that meet the needs of
Indian and multinational companies.
2. To develop the skills among students to analyze real world problem & implement with
computer engineering solution and in multidisciplinary projects.
4. To develop the ability to work with the core competence of computer science &
engineering i.e. software engineering, hardware structure & networking concepts so that
one can find feasible solution to real world problems.
PO2. Problem analysis: Identify, formulate, research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
PO5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
PO6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice. 44
PO8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
PO11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
PO12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change
INDEX
S.
Experiment Name Date Grade Signature
No.
Experiment 1
//1. Write a Program to illustrate the use of classes and object.
#include <iostream.h>
#include<conio.h>
class Student
{ private:
int rollno;
char name[20];
float age;
public:
void getdata()
{
cout<<"\tenter the roll number:";
cin>>rollno;
cout<<"\tenter name of student:";
cin>>name;
cout<<"\tenter the age of student:";
cin>>age;
}
void showdata()
{
cout<<"\n\tRoll Number: "<<rollno;
cout<<"\n\tName of Student: "<<name;
cout<<"\n\tAgeofStudent : "<<age;
}
};
void main()
{
clrscr();
Student s1;
s1.getdata();
s1.showdata();
getch();
}
OUTPUT
Roll Number: 36
Name of Student : Arbaz
Age of student :18
Viva Questions
Q.1 what do you mean by classes?
Ans- A class describes a group of objects with similar properties, common behavior and
common relationship with each other. It is a user-defined data type which has some data
members and member functions.
Experiment 2
//2. Write a Program to illustrate different types of objects as local, global, static dynamic
object.
#include<iostream.h>
#include<conio.h>
class object
{
int value;
public:
object()
{
value=0;
}
voidaddvalue(intvaluein)
{
value+=valuein;
}
intgetvalue()
{
return value;
}
};
object obj1; //global object
void main()
{
clrscr();
object *obj=new object(); //dynamic object
cout<<"\n\tLOCAL-GLOBAL-STATIC-DYNAMIC OBJECT\n\n";
obj1.addvalue(5);
for(int i=0;i<2;i++)
{
object obj2; //local object
obj2.addvalue(10);
static object obj3; //static object created
obj3.addvalue(15);
cout<<"local object has value"<<obj2.getvalue()<<endl;
cout<<"static object has value"<<obj3.getvalue()<<endl;
cout<<"GLOBAL object has value"<<obj1.getvalue()<<endl;
//global either in or out of for always same value
}
getch();
}
OUTPUT
Viva Questions
Q.1 Explain local object and global object?
Ans-
External object- These type of objects are declared like a global object, The
scope of these type of objects is the entire file. The visibility mode of these type
of objects is throughout the program.
Local object- These objects are visible throughout the local scope and has limited
lifetime.
Static Object- These objects are defined locally and the scope and lifetime is
within the program only.
Experiment 3
//3. Program to illustrate the concept of file handling.
#include <iostream>
#include <fstream>
int main()
{
fstream file;
file.open("sample.txt",ios::out);
if(!file)
{
cout<<"Error in creating file!!!";
return 0;
}
file.close();
return 0;
}
OUTPUT
Viva Questions
Q.1 Describe how files can be opened and closed in a program?
Ans- The file operations associated with the object of one of the classes: ifstream, ofstream or
fstream. We need to create a object of corresponding class.
File can be opened by function open (). The syntax of file open is
Open (filename, mode)
Ofstreamobj;
Obj.open(“abc.txt”,ios::out);
Obj.close();
That means file abc.txt is opened in output mode. Function close () is used to close file.
Q.2 Explain the following functions:
1. Seekg() 2. Seekp()
3. Tellg() 4. Tellp()
Ans- seekg() - Sets the position of the get pointer. The get pointer determines the next location to
be read in the source associated to the stream.
Syntax: seekg (position);
seekp()- The seekp method changes the location of a stream object's file pointer for output (put
or write.) In most cases, seekp also changes the location of a stream object's file pointer for input
(get or read.)
seekp ( position );
tellg()- The tellg() function is used with input streams, and returns the current "get" position of
the pointer in the stream.
Syntax: pos_typetellg();
tellp()- Returns the absolute position of the put pointer. The put pointer determines the location
in the output sequence where the next output operation is going to take place.
Syntax: pos_typetellp();
Experiment 4
//4. Write a program to illustrate the use of encapsulation.
#include<iostream>
using namespace std;
class Encapsulation
{
private:
// data hidden from outside world
int x;
public:
// function to set value of
// variable x
void set(int a)
{
x =a;
}
// main function
int main()
{
Encapsulation obj;
obj.set(5);
cout<<obj.get();
return 0;
}
OUTPUT
5
Viva Questions
Q.1 Explain Encapsulation and its importance in programming?
Ans-Wrapping up of data and function into a single unit is known as Encapsulation. It helps to
avoid access to private data members of our class and hence data hiding can be achieved.
Experiment 5
//5. Write a program to illustrate the concept of static data member.
#include <iostream>
using namespace std;
class Demo
{
private:
static int X;
public:
static void fun()
{
cout <<"Value of X: " << X << endl;
}
};
//defining
int Demo :: X =10;
int main()
{
Demo X;
X.fun();
return 0;
}
Output:
Viva Question:
We can define class member’s static using static keyword. When we declare a member of a class
as static it means no matter how many objects of the class are created, there is only one copy of
the static member. A static member is shared by all objects of the class. All static data is
initialized to zero when the first object is created, if no other initialization is present.
Experiment 6
//6. Program to illustrate the concept of constructor and destructor.
#include<conio.h>
#include<iostream.h>
class student{
char name[20],add[20];
int roll;
long zip;
public:
student ( ); // Default Constructor
~student( ); //Destructor
void read( );
void display( );
};
student :: student( )
{
cout<<”This is Student Details”<<endl;
}
void student :: read( ){
cout<<”\nEnter the student Name\n”;
cin>>name;
cout<<”\nEnter the student roll no \n“;
cin>>roll;
cout<<”\nEnter the student address\n”;
cin>>add;
cout<<”\nEnter the Zipcode\n”;
cin>>zip;
}
void student :: display( ){
cout<<”Student Name :”<<name<<endl;
cout<<”Roll no is :”<<roll<<endl;
cout<<”Address is :”<<add<<endl;
cout<<”Zipcode is :”<<zip; }
student : : ~student( )
{
cout<<”Student Detail is Closed”;
}
void main( ){
student s;
clrscr( );
s.read ( );
s.display ( );
getch( );
}
OUTPUT
Arbaz Mansuri
105
Indore
453331
Roll no is :105
Address is : Indore
Zipcode is :453331
Viva Questions
Q.1 Explain the concept of constructor and destructor?
Ans- Constructor is used to initialize the variables and those variables are then used for processing. If variables are
not initialized then it contains some garbage value. Constructor has no return type and name same as class name.
Destructor is used to destroy or used to free up the memory occupied by our object. It is followed by a tilde sign
(~), as constructors it has no return type and has same name as class name.
Q.2 Explain types of constructor?
Ans.There are 3 basic type of constructor:-
Default Constructor- A Default constructor has either no parameter, or it has parameters, all the
parameters have default values. if no user-defined constructor exists then compiler provides default
constructor implicitly.
Parameterized Constructor- When a object is declared in parameterized constructor, the initial values
have to be passed as arguments to the constructor function.
Copy Constructor- The copy constructor is a constructor which creates an object by initializing it with an object of
the same class, Which has been created previously. The copy constructor is used to initialize one object from
another of the same type.
Experiment 7
// 7. Write a Program to illustrate different types of inheritance:
// 7.1 Single Inheritance
#include <iostream>
using namespace std;
// base class
class Vehicle {
public:
Vehicle()
{
cout << "This is a Vehicle" << endl;
}
};
};
// main function
int main()
{
// creating object of sub class will
// invoke the constructor of base classes
Car obj;
return 0;
}
OUTPUT
This is a vehicle
//7.2 Hierarchical Inheritance
#include <iostream>
using namespace std;
// base class
class Vehicle
{
public:
Vehicle()
{
cout << "This is a Vehicle" << endl;
}
};
};
};
// main function
int main()
{
// creating object of sub class will
// invoke the constructor of base class
Car obj1;
Bus obj2;
return 0;
}
OUTPUT
This is a Vehicle
This is a Vehicle
//7.3 Multilevel Inheritance
#include <iostream>
using namespace std;
class Vehicle
{
public:
Vehicle()
{
cout << "This is a Vehicle" << endl;
}
};
class fourWheeler: public Vehicle
{ public:
fourWheeler()
{
cout<<"Objects with 4 wheels are vehicles"<<endl;
}
};
class Car: public fourWheeler{
public:
car()
{
cout<<"Car has 4 Wheels"<<endl;
}
};
int main()
{
Car obj;
return 0;
}
OUTPUT
This is a Vehicle
Objects with 4 wheels are vehicles
Car has 4 Wheels
{
cout << "This is a 4 wheeler Vehicle" << endl;
}
};
class Car: public Vehicle, public FourWheeler {
};
int main()
{
Car obj;
return 0;
}
OUTPUT
This is a Vehicle
This is a 4 wheeler Vehicle
Fare()
{
cout<<"Fare of Vehicle\n";
}
};
class Car: public Vehicle
{
};
class Bus: public Vehicle, public Fare
{
};
int main()
{
Bus obj2;
return 0;
}
OUTPUT
This is a Vehicle
Fare of Vehicle
Viva Questions
Q.1 what is inheritance? Explain different type of inheritance?
Ans- Inheritance is a property in which some of the properties and methods of base class can be
derived by the derived class.
TYPES OF INHERITANCE:
Single Inheritance: In single inheritance there is one parent class. This is the most
common form of inheritance.
Multiple inheritance: In multiple inheritance the derived from more than one base class.
Multi-level inheritance: When a derived class is derived from a base class which itself is
a derived class then that type of inheritance is called multilevel inheritance.
Hybrid inheritance: When two or more type of inheritances are combined together then
it forms the hybrid inheritance. It is combination of multiple and hierarchical inheritance.
Hierarchical inheritance: When several base classes are derived from single base class
then it is known as hierarchicalinheritance.
Experiment 8
//8. Write a Program to illustrate the concept of Aggregation.
#include <iostream>
using namespace std;
class Address {
public:
string addressLine, city, state;
Address(string addressLine, string city, string state)
{
this->addressLine = addressLine;
this->city = city;
this->state = state;
}
};
class Employee
{
private:
Address* address; //Employee HAS-A Address
public:
int id;
string name;
Employee(int id, string name, Address* address)
{
this->id = id;
this->name = name;
this->address = address;
}
void display()
{
cout<<id <<" "<<name<< " "<<
address->addressLine<< " "<< address->city<< " "<<address->state<<endl;
}
};
int main(void) {
Address a1= Address("C-146, Sec-15","INDORE","MP");
Employee e1 = Employee(101,"ARBAZ",&a1);
e1.display();
return 0;
OUTPUT
101 ARBAZ C-146, Sec-15 INDORE MP
Viva Questions:
Q.1 what do you mean by term aggregation?
Ans- Aggregation is used to represent the whole to a part relationship. It normally posses the
Has-a relationship. It is denoted by-
-----------------<>
Q.2 Explain different types of Aggregation?
Ans-
Fixed Aggregation: In this type of aggregation the number and types of the
component parts are fixed are predefined.
Experiment 9
//9.Write a program to illustrate the concept of static polymorphism.
//9.1 Function Overloading
#include <iostream>
using namespace std;
void print(int i) {
cout << " Here is int " << i << endl;
}
void print(double f) {
cout << " Here is float " << f << endl;
}
void print(char const *c) {
cout << " Here is char* " << c << endl;
}
int main() {
print(10);
print(10.10);
print("ten");
return 0;
}
OUTPUT
Here is int 10
Here is float 10.1
Here is char* ten
#include<iostream>
using namespace std;
int mul(int,int);
float mul(float,int);
float r2 = mul(0.2,3);
std::cout << "r1 is : " <<r1<< std::endl;
std::cout <<"r2 is : " <<r2<< std::endl;
return 0;
}
OUTPUT
r1 is : 42
r2 is : 0.6
Viva Questions
(a) Function overloading: Overloading means to use of the same thing for different purposes,
C++ also permits overloading of functions by the use of same functions name to create functions
that perform a variety of task.
(b) Operator overloading: Operator overloading provide multiple meanings to the set of
predefined operators of the compiler. So as to use it for multiple tasks.
Experiment 10
//10. Program to illustrate the concept of dynamic polymorphism
#include <iostream>
using namespace std;
class Shape {
protected:
int width, height;
public:
Shape( int a = 0, int b = 0){
width = a;
height = b;
}
int area() {
cout << "Parent class area :" <<endl;
return 0;
}
};
class Rectangle: public Shape {
public:
int area () {
cout << "Rectangle class area :" <<endl;
return (width * height);
}
};
int area () {
cout << "Triangle class area :" <<endl;
return (width * height / 2);
}
};
return 0;
}
OUTPUT
Parent class area :
Parent class area :
Viva Questions
Q.1 what do you mean by Dynamic polymorphism?
Ans- Dynamic polymorphism is also known as run-time polymorphism. Dynamic (run
time) polymorphism is the polymorphism existed at run-time. Here, Java compiler does not
understand which method is called at compilation time. Only JVM decides which method is
called at run-time. Method overloading and method overriding using instance methods are the
examples for dynamic polymorphism.
Q.2 what are the difference between Static and Dynamic polymorphism?
Ans-
STATIC POLYMORPHISM DYNAMIC POLYMORPHISM
It is also known as Static binding, Early It is also known as Dynamic binding, Late
binding and overloading as well. binding and overriding as well.
Compile time polymorphism is less flexible as Run time polymorphism is more flexible as
all things execute at compile time. all things execute at run time.
Experiment 11
class Testimmutablestring1
{
public static void main(String args[]){
String s1="Arbaz";
String s2="ARBAZ";
//System.out.println(s1.equals(s2));
String s="Arbaz";
s=s.concat(" Mansuri");
System.out.println(s.substring(6));
System.out.println(s1.equalsIgnoreCase(s2));//true
System.out.println(s1==s2);
System.out.println(s1.compareTo(s2));
System.out.println(s);
}
}
OUTPUT
Mansuri
true
false
32
Arbaz Mansuri
Viva Questions
Q. 1 Why is String final in Java?
There are a couple of reasons for this e.g. String pool, Caching, Performance but Security is
probably the most important reason. Given String is used in sensitive places like specifying the
host and port details, locking it for modification prevent from may Security related risks.
Experiment 12
Output-
In the catch Block due to Exception = java.lang.ArithmeticException: / by zero
End Of Main
Viva Questions
Q.1 what do you mean by an Exception?
Ans- An exception is a problem that arises during the execution of a program. A C++ exception
is a response to an exceptional circumstance that arises while a program is running, such as an
attempt to divide by zero.
Exceptions provide a way to transfer control from one part of a program to another. C++
exception handling is built upon three keywords: try, catch, and throw.
Q.2 Explain blocks contained in an Exception handler?
Ans-
Try block:
Statements which will raise errors at runtime are written in this block.
Syntax-
try(Expression);
Catch block: Runtime errors are caught by the catch block; It catches the Exception
thrown by the throw statement in try block.
Syntax-
catch()
{
-------------
}
Throw block: If an Exception occurs in try block then it is thrown by this statement.
Syntax:
Throw(object)
{
------------;
------------;
}
Experiment 13
//13. Program to illustrate the concept of multithreading.
class Multi extends Thread{
public void run(){
System.out.println("thread is running...");
}
public static void main(String args[]){
Multi t1=new Multi();
t1.start();
}
}
Output
thread is running...
class Multi3 implements Runnable{
public void run(){
System.out.println("thread is running...");
}
public static void main(String args[]){
Multi3 m1=new Multi3();
Thread t1 =new Thread(m1);
t1.start();
}
}
Out put
thread is running...
Viva Questions
Q.1 what is Thread.
The thread is a program execution that uses process resources for accomplishing the task. All
threads within a single program are logically contained within a process. The kernel allocates a
stack and a thread control block (TCB) to each thread. The operating system saves only the stack
pointer and CPU state at the time of switching between the threads of the same process.
Q.2 what is Multithreading and Multitasking.
Comparison Chart
Basis for
Multitasking Multithreading
Comparison
#include <iostream.h>
#include <conio.h>
char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
intcheckwin();
void board();
void main()
{
int player = 1,i,choice;
char mark;
clrscr();
do
{
board();
player=(player%2)?1:2;
cout<< "Player " << player << ", enter a number: ";
cin>> choice;
mark=(player == 1) ? 'X' : 'O';
if (choice == 1 && square[1] == '1')
square[1] = mark;
else if (choice == 2 && square[2] == '2')
square[2] = mark;
else if (choice == 3 && square[3] == '3')
square[3] = mark;
else if (choice == 4 && square[4] == '4')
square[4] = mark;
else if (choice == 5 && square[5] == '5')
square[5] = mark;
}
intcheckwin()
{
if (square[1] == square[2] && square[2] == square[3])
return 1;
else if (square[4] == square[5] && square[5] == square[6])
return 1;
else if (square[7] == square[8] && square[8] == square[9])
return 1;
else if (square[1] == square[4] && square[4] == square[7])
return 1;
else if (square[2] == square[5] && square[5] == square[8])
return 1;
else if (square[3] == square[6] && square[6] == square[9])
return 1;
else if (square[1] == square[5] && square[5] == square[9])
return 1;
else if (square[3] == square[5] && square[5] == square[7])
return 1;
else if (square[1] != '1' && square[2] != '2' && square[3] != '3' &&
square[4] != '4' && square[5] != '5' && square[6] != '6' &&
OUTPUT:
Viva Question:
Q.1 How to find the winner of a tic-tac-toe game of any size?
Ans- To start, have an array of numbers for each row, column, and diagonal for each player. On
each move, increment the elements corresponding to the player for the row, column, and
diagonal (the move may not necessarily be on a diagonal) influenced by that move. If the count
for that player is equal to the dimension of the board, that player wins.
Q.2 What does checkwin() function do?
Ans- It helps to find which checked block so that no two blocks can be shared by different player
and they put their symbols one by one and finally display the winner.
Experiment 15
//15. Write a program to implement Template using C++.
15.1- Function Template
#include <iostream>
using namespace std;
template<class T> T add(T &a,T &b)
{
T result = a+b;
return result;
}
int main()
{
int i =2;
int j =3;
float m = 2.3;
float n = 1.2;
cout<<"Addition of i and j is :"<<add(i,j);
cout<<'\n';
cout<<"Addition of m and n is :"<<add(m,n);
return 0;
}
Output
Addition of i and j is :5
Addition of m and n is :3.5
{
std::cout << "Values of a and b are : " << a<<" ,"<<b<<std::endl;
}
};
int main()
{
A<int,float> d(5,6.5);
d.display();
return 0;
}
Output-
Values of a and b are : 5 ,6.5
Viva Questions:
Q.1 What do you mean by templates?
Templates are a feature of the C++ programming language that allows functions and classes to
operate with generic types. This allows a function or class to work on many different data types
without being rewritten for each one.