GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab GGS College of Modern Technology, Kharar (Mohali)-Punjab (Approved by AICTE & Affiliated to Punjab Technical University, Jalandhar) PRACTICAL FILE CSE/IT DEPARTMENT GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR Approved by AICTE& Affiliated to PTU, Jalandhar 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
GGS College of Modern Technology,
Kharar (Mohali)-Punjab
(Approved by AICTE & Affiliated to Punjab Technical University, Jalandhar)
PRACTICAL FILECSE/IT DEPARTMENT
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR
Approved by AICTE& Affiliated to PTU, Jalandhar
1
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
CSE/IT DEPARTMENT
LABORATORY REPORT(DSPM LAB)
NAME OF STUDENT______________________ROLL NO._______________________________SEMESTER _____________________________SESSION ________________________________
STUDENT SIGNATURE__________
FACULTY SIGNATURE_______
2
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
COURSE OBJECTIVE This Guide is designed for helping the students to perform better in various practical
courses. It describes the structure of a good laboratory report, outlines the different sections of the report and explains the need for each of them. It also introduces some standard conventions and rules for writing reports of professional quality. The quality of your written report will strongly affect your grade for the course.
EVALUATION OF PRACTICAL WORK
Each student will be required to perform the experiment individually. Student will be required to write theory, algorithm, program, outputs etc.
during practical session itself. Each experiment will be marked by the teacher on the basis of experiment
performed and write up on the same day. These marks will account for 40% of the sessional marks.
Sessional marks will also include VIVA and Attendance marks as per rules.
GOOD LABORATORY PRACTICES
You must develop good laboratory habits by keeping complete laboratory note books.
Keep all your notes about the laboratory procedures and data in this notebook in pen.
It is always better to read experiment in advance. The expectation is that you will work individually on separate computers. Each
of you will write a separate report. Please bring your laboratory manual to the lab on every turn.
3
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
THINGS TO DO AND DON’T DO IN THE LABORATORY
DO’S
Remember this is a practice laboratory & keep silence. Sit down in proper manner. Laboratory instructor can help to access software and printer. If require more in depth help you can concern lecturer. Proper shut down the computer system before leaving the laboratory. Exit laboratory quickly, if short circuit or any emergency occurs.
DON’T
Write anything on the furniture. Delete or change other student’s file. Uninstall the software. Create, change or remove any password. Play computer games.
List of Experiments
4
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
Sr. No.
List of Experiments Date of performance
Teacher’s signature
Marks
1 Write a program in C++ to traversing an array
2 Write a program in C++ for inserting an array.
3 Write a program in C++ for deleting an array.
4 Write a program in C++ for linear search.
5 Write a program in C++ for binary search.
6 Write a program in C++ for bubble sort.
7 Write a program in C++ to push the elements into stack.
8 Write a program in C++ to pop an element from stack.
9 Write a program in C++ to sort a list using selection sort.
10 Write a program in C++ to sort a list using insertion sort.
11 Write a program in C++ to insert an element into a queue.
AIM Write a program in C++ to Traversing an Array.
5
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
Experiment No 1 Date__/__/_____
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
void main()
{
void print(long []);
long profit[5]={400000,250000,450000,500000,5500000};
clrscr();
print(profit);
getch();
}
void print(long profit[])
{
int str_year=1950;
cout<<"year"<<setw(15)<<" profit"<<endl;
cout<<"................"<<endl<<endl;
for(int i=0;i<5;i++)
6
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labcout<<str_year+i<<setw(15)<<profit[i]<<endl;
}
7
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabOutput:
Year profit
................
1950 400000
1951 250000
1952 450000
1953 500000
1954 5500000
8
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
Viva-voce Questions:
What so you understand by a data structure?
Name any five data structures.
What are arrays?
What are the types of arrays?
How two dimensional arrays are stored in memory?
9
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabExperiment No 2 Date__/__/_____
AIM Write a program in C++ for Inserting an Array.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int a[20],n,k,item;
clrscr();
void insert(int a[],int n,int k,int item);
cout<<"enter the no of elements";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"enter the element a[" <<i<<"]=";
cin>>a[i];
}
cout<<"enter the item to insert=";
cin>>item;
cout<<"enter index position of new item";
cin>>k;
10
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labinsert(a,n,k,item);
cout<<"elements after insertion"<<endl;
for( i=0;i<=n;i++)
{
cout<<setw(4)<<a[i];
}
getch();
}
void insert(int a[],int n,int k,int item)
{
int i=n-1;
while(i>=k)
{
a[i+1]=a[i];
i=i-1;
}
a[k]=item;
n=n+1;
}
11
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
Output:
enter the no of elements5
enter the element a[0]=7
enter the element a[1]=21
enter the element a[2]=9
enter the element a[3]=10
enter the element a[4]=4
enter the item to insert=13
enter index position of new item3
elements after insertion
7 21 9 13 10 4
12
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
Viva-voce Questions :
What will happen when you delete in an empty array?
What will happen when you insert in a completely filled array?
What ‘5’ signifies in “A[5]”?
What is garbage collection?
Can you insert in middle location of an array?
AIM Write a program in C++ for Deleting an Array.
13
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab
Experiment No 3 Date__/__/_____
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int a[20],n,k,item;
clrscr();
void delete2(int a[],int &n,int k);
cout<<"enter the number of element (<=20) =";
cin>>n;
for (int i=0; i<n; i++)
{
cout <<"enter element a["<<i<<"]=";
cin>>a[i];
}
cout<<"enter position of element you want to delete :";
cin>>k;//index of element to delete is k-1
delete2(a,n,k-1);
14
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab cout<<"elements after deletion:\n";
for(i=0;i<n;i++)
cout<<setw(4)<<a[i];
getch();
}
void delete2(int a[],int &n,int k)
{
for (int i=k; i<=n-2;i++)
a[i]=a[i+1];
n=n-1;
}
15
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabOUTPUT:
enter the number of element (<=20) =5
enter element a[0]=10
enter element a[1]=12
enter element a[2]=13
enter element a[3]=15
enter element a[4]=14
enter position of element you want to delete :3
elements after deletion:
10 12 15 14
16
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabViva-voce Questions:
What is the principle of stack?
What do you understand by top pointer?
What is overflow?
What is underflow?
Can you insert at middle in a stack?
Experiment No 4 Date__/__/_____
17
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabAIM Write a program in C++ for Linear Search .
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
clrscr();
int a [15],i,n,item,loc;
int lsrch(int a[],int n,int item);
cout<<"enter the element of array.... ";
cin>>n;
for(i=0;i<5;i++)
{ cout<<"the elements of array a["<<i<<"]..";
cin>>a[i];
}
cout<<"enter the element you want to search......";