SlideShare a Scribd company logo
//bubble sort
#include<iostream.h>
#include<conio.h>
void main ()
{
int a[8] = {22,33,55,44,11,77,11,66};
int k,ptr,temp;
const int n = 8;
clrscr();
for(k=0;k<=n-2;k++)
{
ptr=0;
while (ptr<=n-k-2)
{
if(a[ptr] > a[ptr+1])
{
temp = a[ptr];
a[ptr] = a[ptr+1];
a[ptr+1] = temp;
}
ptr = ptr+1;
}
}
for(k=0;k<=7;k++)
cout<<a[k]<<"t";
getch();
}
// insertion sort
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int array[10],i,j,k,temp, loc;
cout<<"enter the array"<<endl;
for(i=0;i<=9;i++)
cin>>array[i];
//insertion sort logic
for (i=1;i<=9;i++)
{
temp=array[i];
loc=i;
for (j=i;j>=1;j--)
{
if (temp < array[j-1])
{
array[j] = array[j-1];
loc=j-1;
}
else
break;
}
array[loc]=temp;
}
cout<<"sorted arry"<<endl;
for(k=0;k<=9;k++)
cout<<array[k]<<" ";
getch();
}
//sum of two variables( not in salybas)
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,sum;
a=3;
b=5;
sum=a+b;
cout<<"enter the first numbr"<<a;
cin>>a;
cout<<"enter the second number"<<b;
cin>>b;
cout<<"sum is "<<sum;
cin>>sum;
getch();
}
// to find the angle( not in salybas)
#include<iostream.h>
#include<conio.h>
void main()
{
int degree,angle;
cout<<"enter the degree";
cin>>degree;
{
if(degree<90)
cout<<"the angle is = acute angle";
else
if(degree>90)
cout<<"the angle is = obtus angle";
else
if(degree==90)
cout<<"the angle is = right angle";
}
getch();
}
// to find the largest element
#include<iostream.h>
#include<conio.h>
void main ()
{
int k,i,loc,max,a[5];
clrscr();
cout<<"enter the 5 element"<<endl;
for(i=0;i<=4;i++)
cin>>a[i];
k=0;
loc=0;
max=a[0];
while(k<=4)
{
if(max<a[k])
{
loc=k;
max=a[k];
}
k=k++;
}
cout<< "locatin is"<<loc<<" "<<"number is "<<max;
getch();
}
// selection sort
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arry[10],i,j,k,temp;
cout<<"enter the array"<<endl;
for(i=0;i<8;i++)
cin>>arry[i];
for(i=0;i<8;i++)
for(j=i+1;j<8;j++)
if(arry[i] > arry[j])
{
temp = arry[i];
arry[i] = arry[j];
arry[j] = temp;
}
cout<<"sorted arry"<<endl;
for(k=0;k<8;k++)
cout<<arry[k]<<" ";
getch();
}
//linear search
#include<iostream.h>
#include<conio.h>
void main()
{
int item,data[10] = {33,44,55,22,11,66,99,88,77,60},k,loc;
clrscr();
cout<<"enter the value to search"<<endl;
cin>>item;
loc=-1;
k = 0;
while (loc==-1 && k<=9)
{
if(item==data[k])
loc=k;
k = k+1;
}
if(loc==-1)
cout<<"item is not in an array";
else
cout<<loc<<"t"<<"is the location of an item";
getch();
}
// quadric equation
#include<iostream.h>
#include<conio.h>
void main ()
{
int a,b,c,d,x,x1,x2;
clrscr();
cout<<"enter three values"<<endl;
cin>>a>>b>>c;
d= b*b -4*a*c;
if(d>0)
{
x1=(-b+d^(1/2));
x2=(-b-d^(1/2));
cout<<x1<<"t"<<x2;
}
else
if(d==0)
{
x=-b/2*a;
cout<<"uniqe solution"<<x;
}
else
cout<<"no real soltuion";
getch();
}

More Related Content

What's hot (20)

PDF
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
PDF
Powered by Python - PyCon Germany 2016
Steffen Wenz
 
DOCX
Doubly linklist
ilsamaryum
 
PDF
Меняем javascript с помощью javascript
Pavel Volokitin
 
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
PDF
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
PPT
NS2: Binding C++ and OTcl variables
Teerawat Issariyakul
 
KEY
Grand centraldispatch
Yuumi Yoshida
 
ODP
To Infinity & Beyond: Protocols & sequences in Node - Part 2
Bahul Neel Upadhyaya
 
PDF
Cluj Big Data Meetup - Big Data in Practice
Steffen Wenz
 
PDF
Understanding the nodejs event loop
Saurabh Kumar
 
DOCX
Aa
Akshay Kumar
 
PDF
Performance testing of microservices in Action
Alexander Kachur
 
PPTX
Mysql handle socket
Philip Zhong
 
PPTX
Mysql5.1 character set testing
Philip Zhong
 
PDF
The Ring programming language version 1.3 book - Part 48 of 88
Mahmoud Samir Fayed
 
PDF
Google App Engine Developer - Day3
Simon Su
 
TXT
Problemas de Arreglos en c++
Manfred Ariel Martinez Bastos
 
PDF
3 rd animation
divyalakshmi77
 
PPTX
Compare mysql5.1.50 mysql5.5.8
Philip Zhong
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
Powered by Python - PyCon Germany 2016
Steffen Wenz
 
Doubly linklist
ilsamaryum
 
Меняем javascript с помощью javascript
Pavel Volokitin
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
NS2: Binding C++ and OTcl variables
Teerawat Issariyakul
 
Grand centraldispatch
Yuumi Yoshida
 
To Infinity & Beyond: Protocols & sequences in Node - Part 2
Bahul Neel Upadhyaya
 
Cluj Big Data Meetup - Big Data in Practice
Steffen Wenz
 
Understanding the nodejs event loop
Saurabh Kumar
 
Performance testing of microservices in Action
Alexander Kachur
 
Mysql handle socket
Philip Zhong
 
Mysql5.1 character set testing
Philip Zhong
 
The Ring programming language version 1.3 book - Part 48 of 88
Mahmoud Samir Fayed
 
Google App Engine Developer - Day3
Simon Su
 
Problemas de Arreglos en c++
Manfred Ariel Martinez Bastos
 
3 rd animation
divyalakshmi77
 
Compare mysql5.1.50 mysql5.5.8
Philip Zhong
 

Similar to Data structure programs in c++ (20)

RTF
Sortings
maamir farooq
 
DOCX
Assignment
Ayesha Bhatti
 
PDF
888678123317368915236 #include stdio.h #include stdlib.h.pdf
apnafreez
 
PPT
Class5_ADT_Array_Sorting_Rank-Buble-Complexity_12Jan2023.ppt
ee23bt028
 
PDF
#include iostream using namespace std; void InsertionSort(int .pdf
brijmote
 
PDF
C++ Searching & Sorting5. Sort the following list using the select.pdf
Rahul04August
 
PPT
Sorting
Govind Upadhyay
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
arwholesalelors
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
PDF
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
PDF
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
PDF
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
Sortings
maamir farooq
 
Assignment
Ayesha Bhatti
 
888678123317368915236 #include stdio.h #include stdlib.h.pdf
apnafreez
 
Class5_ADT_Array_Sorting_Rank-Buble-Complexity_12Jan2023.ppt
ee23bt028
 
#include iostream using namespace std; void InsertionSort(int .pdf
brijmote
 
C++ Searching & Sorting5. Sort the following list using the select.pdf
Rahul04August
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
arwholesalelors
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
Ad

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
July Patch Tuesday
Ivanti
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Ad

Data structure programs in c++

  • 1. //bubble sort #include<iostream.h> #include<conio.h> void main () { int a[8] = {22,33,55,44,11,77,11,66}; int k,ptr,temp; const int n = 8; clrscr(); for(k=0;k<=n-2;k++) { ptr=0; while (ptr<=n-k-2) { if(a[ptr] > a[ptr+1]) { temp = a[ptr]; a[ptr] = a[ptr+1]; a[ptr+1] = temp; } ptr = ptr+1; } } for(k=0;k<=7;k++) cout<<a[k]<<"t"; getch(); } // insertion sort #include<iostream.h> #include<conio.h> void main() { clrscr(); int array[10],i,j,k,temp, loc; cout<<"enter the array"<<endl; for(i=0;i<=9;i++) cin>>array[i]; //insertion sort logic for (i=1;i<=9;i++) { temp=array[i];
  • 2. loc=i; for (j=i;j>=1;j--) { if (temp < array[j-1]) { array[j] = array[j-1]; loc=j-1; } else break; } array[loc]=temp; } cout<<"sorted arry"<<endl; for(k=0;k<=9;k++) cout<<array[k]<<" "; getch(); } //sum of two variables( not in salybas) #include<iostream.h> #include<conio.h> void main() { int a,b,sum; a=3; b=5; sum=a+b; cout<<"enter the first numbr"<<a; cin>>a; cout<<"enter the second number"<<b; cin>>b; cout<<"sum is "<<sum; cin>>sum; getch(); } // to find the angle( not in salybas) #include<iostream.h> #include<conio.h> void main() { int degree,angle; cout<<"enter the degree"; cin>>degree;
  • 3. { if(degree<90) cout<<"the angle is = acute angle"; else if(degree>90) cout<<"the angle is = obtus angle"; else if(degree==90) cout<<"the angle is = right angle"; } getch(); } // to find the largest element #include<iostream.h> #include<conio.h> void main () { int k,i,loc,max,a[5]; clrscr(); cout<<"enter the 5 element"<<endl; for(i=0;i<=4;i++) cin>>a[i]; k=0; loc=0; max=a[0]; while(k<=4) { if(max<a[k]) { loc=k; max=a[k]; } k=k++; } cout<< "locatin is"<<loc<<" "<<"number is "<<max; getch(); } // selection sort #include<iostream.h> #include<conio.h> void main() { clrscr(); int arry[10],i,j,k,temp;
  • 4. cout<<"enter the array"<<endl; for(i=0;i<8;i++) cin>>arry[i]; for(i=0;i<8;i++) for(j=i+1;j<8;j++) if(arry[i] > arry[j]) { temp = arry[i]; arry[i] = arry[j]; arry[j] = temp; } cout<<"sorted arry"<<endl; for(k=0;k<8;k++) cout<<arry[k]<<" "; getch(); } //linear search #include<iostream.h> #include<conio.h> void main() { int item,data[10] = {33,44,55,22,11,66,99,88,77,60},k,loc; clrscr(); cout<<"enter the value to search"<<endl; cin>>item; loc=-1; k = 0; while (loc==-1 && k<=9) { if(item==data[k]) loc=k; k = k+1; } if(loc==-1) cout<<"item is not in an array"; else cout<<loc<<"t"<<"is the location of an item"; getch(); } // quadric equation #include<iostream.h> #include<conio.h> void main () { int a,b,c,d,x,x1,x2;
  • 5. clrscr(); cout<<"enter three values"<<endl; cin>>a>>b>>c; d= b*b -4*a*c; if(d>0) { x1=(-b+d^(1/2)); x2=(-b-d^(1/2)); cout<<x1<<"t"<<x2; } else if(d==0) { x=-b/2*a; cout<<"uniqe solution"<<x; } else cout<<"no real soltuion"; getch(); }