SlideShare a Scribd company logo
1 of 20
• Find the factorialof a number.
#include<iostream.h>
#include<conio.h>
void main()
{
intn,fact;
int rec(int);
clrscr();
cout<<"enter the number:-";
cin>>n;
fact=rec(n);
cout<<endl<<"factorial results are::"<<fact<<endl;
getch();
}
rec(int x)
{
int f;
if(x==1)
return(x);
else
f=x*rec(x-1);
return(f);
}
OUTPUT:-
2. Insertthe elementinto an array.
#include<stdio.h>
#include<conio.h>
#include<process.h>
intarr[10],n,i,j,k,item,loc;
void main()
{
clrscr();
printf("n enter the size of array");
scanf("%d",&n);
if(n>10)
{
printf("n entered value exceed the limit of array");
getch();
}
printf("n enter array element ..");
for(i=1;i<=n;i++)
scanf("%d",&arr[i]);
printf("enter the element to inserted...");
scanf("%d",&item);
for(j=n-1;j<=loc;j++)
arr[j+1]=arr[j];
arr[loc]=item;
printf("n array after insertion..");
k=0;
while(k<=n)
{
printf("n");
printf("%d",arr[k]);
k=k+1;
}
getch();
}
OUTPUT:-
3. Deleting the elements from array.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,k,item,i;
void delete(int a[],int *,int k);
clrscr();
printf("enter no. of element=");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("n enter element a[%d]=",i);
scanf("%d", &a[i]);
}
printf("enter position of element you want to be deleted:");
scanf("%d",&k);
delete(a,&n,k-1);
printf("element after deletion:n");
for(i=0;i<n;i++)
printf("%d",a[i]);
getch();
}
void delete(int a[],int *size1,int k)
{
int n1=*size1;
inti;
for(i=k;i<n1-2;i++)
a[i]=a[i+1];
*size1=*size1-1;
}
OUTPUT:-
4.Traversing the elements in array.
#include<stdio.h>
#include<conio.h>
void main()
{
void print1(long[]);
long profit[5]={50000,10000,20000,75000,30000};
clrscr();
print1(profit);
getch();
}
void print1(long profit[])
{
inti;
intst_year=1950;
printf("yearttprofitn");
printf("--------n");
for(i=0;i<5;i++)
printf("%dtt%dn",st_year +i,profit[i]);
}
Output:-
5. Program for the bubble sort.
#include<iostream.h>
#include<conio.h>
void main()
{
intarr[5];
cout<<"enter 5 number randomly:";
for(inti=0;i<5;i++)
{
cin>>arr[i];
}
cout<<"ninput array is:";
for(int j=0;j<5;j++)
{
cout<<"n value at"<<j<<"index:"<<arr[j];
}
int temp;
for(int i2=0;i2<4;i2++)
{
for(int j=0;j<4;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
} } }
cout<<"nsorting array is:";
for(int i3=0;i3<5;i3++)
{
cout<<"n value at"<<i3<<"index:"<<arr[i3]; }
getch(); }
OUTPUT:-
6. Selection sort.
#include<stdio.h>
#include<conio.h>
int m;
int minimum(int *,int);
voidselect_sort(int *);
int minimum(int a[],inti)
{
intmini,loc;
mini=a[i];
loc=i;
while(i<m)
{
if(mini>a[i+1])
{
mini=a[i+1];
loc=i+1;
}
i++;
}
return(loc);
}
voidselect_sort(int a[])
{
inttemp,i=1,
loc;
for(i=1;i<m;i++)
{
loc=minimum(a,i);
temp=a[i];
a[i]=a[loc];
a[loc]=temp;
}
}
void display(int a[])
{
inti;
for(i=0;i<m;i++)
printf("ntt list[%d]=%d",i,a[i]);
}
void main()
{
int a[20];
inti;
clrscr();
printf("n how many element you want to insert:");
scanf("%d",&m);
printf("n enter the element");
for(i=0;i<m;i++)
{
printf("n a[%d]=",i);
scanf("%d",&a[i]);
}
printf("ntt");
printf("nt list before sorting:n");
display(a);
select_sort(a);
printf("nnt");
printf("nt list after sorting:");
printf("nt....");
display(a);
getch();
}
OUTPUT:-
7.Insertion sort.
#include<stdio.h>
#include<conio.h>
int m;
voidinsertion_sort(int *);
void display(int *);
voidinsertion_sort(int a[])
{
intele,i;
for(i=1;i<m;i++)
{
ele=a[i];
while(ele<a[i-1]&&i>0)
{
a[i]=a[i-1];
i--;
}
a[i]=ele;
}
}
void display(int a[])
{
inti;
for(i=0;i<m;i++)
printf("nt list[%d]=%d",i,a[i]);
}
void main()
{
int a[20];inti;
clrscr();
printf("n how many element you want to inert :");
scanf("%d",&m);
printf("n enter the element :");
for(i=0;i<m;i++)
{
printf("n a[%d]=",i);
scanf("%d",&a[i]);
}
printf("nt..");
printf("nt list before sorting:");
printf("nt...");
display(a);
insertion_sort(a);
printf("ntt...");
printf("nt....");
display(a);
getch();
}
OUTPUT:-
8.Linear search.
#include<stdio.h>
#include<conio.h>
void main()
{
intarr[10],n,i,item,loc;
clrscr();
printf("enter the size of array:");
scanf("%d",&n);
printf("n enter array element...");
for(i=1;i<=n;i++)
{
scanf("%d",&arr[i]);
}
printf("enter the element to be search");
scanf("%d",&item);
for(i=1;i<=n;i++)
if(arr[i]==item)
{
loc=i;
printf("n element found of location %d",loc);
}
getch();
}
OUTPUT:-
9.Binary search.
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define true 1
#define false 0
intarr[10],n,i,item,loc,flag=0,low,high,middle;
void main()
{
clrscr();
printf("enter the size of array:");
scanf("%d",&n);
if(n>10)
{
printf("entered value exceed the limit of array");
getch();
exit(0);
}
printf("n enter array element ..");
for(i=1;i<=n;i++)
scanf("%d",&arr[i]);
printf("enter the element to be searched");
scanf("%d",&item);
low=0;
high=n-1;
while(low<=high && flag==0)
middle=(low+high)/2;
if(item<arr[middle])
high=middle-1;
else if(item>arr[middle])
low=middle+1;
{
flag=1;
loc=middle;
}
}
if (flag==1)
{
printf("n element found at location %d",loc);
}
else
{
printf("n element not found...");
getch();
}
OUTPUT:-
10. Enter the elementinto an array.
#include<stdio.h>
#include<conio.h>
void main()
{
intn,i,k,lb,ub,a[10];
clrscr();
printf("n enter the total no. of element of array:");
scan("%d",&n);
printf("nenter the element in array:");
for(i=1;i<=n;i++)
{
printf("element no.[%d] is ",i);
scanf("%d",a[i]);
}
lb=1;
ub=n;
k=lb;
printf("nn");
while(k<=ub)
{
printf("element no.[%d] is %dn",k,a[k]);
k=k+1;
}
getch();
}
OUTPUT:-
11.Pushoperation in a stack.
#include<stdio.h>
#include<conio.h>
#define max 100
int top=-1;
int flag=0;
int stack[max];
void push(int *,int);
int pop(int *);
void display(int *);
void push(int stack[],int item)
{
if(top==(max-1));
flag=0;
{
flag=1;
top++;
stack[top]=item;
}
}
int pop(int stack[])
{
int item;
if(top<0);
{
item=0;
flag=0;
}
{
flag=1;
item=stack[top];
top--;
}
return(item);
}
void display(int stack[])
{
inti;
if(top==-1)
{
printf("nntt stack is empty");
}
else
{
for(i=top;i>=0;i--)
printf("nntt stack[%d]=%d",i,stack[i]);
}
}
void main()
{
intn,i,item,f=1;
clrscr();
printf("nntt");
printf("ntt stack is empty");
printf("nn push some item on to stack");
printf("nn how many item you want to push:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("nn enter item:");
push(stack,item);
if(flag)
{
printf("nntt");
printf("ntt");
printf("nntt stack after operation:n");
printf("ntt");
display(stack);
}
else
{
printf("nntt");
printf("ntt stack is full");
printf("ntt");
}
}
while(f==1)
{
item=pop(stack);
if(flag)
{
printf("nn the popod item is %d",item);
printf("nntt stack after pop opreation:n");
printf("ntt");
display(stack);
}
else
{
printf("nntt");
printf("nntt stack is empty");
printf("nnttt");
}
printf("nnpop again(1/0):");
scanf("%d", &f);
}
getch();
}
OUTPUT:-
12.Insertitem into queue.
#include<stdio.h>
#include<conio.h>
#include<process.h>
intque[10],i,max, item,front=-1,rear=-1,n;
void main()
{
clrscr();
printf("enter size of cicular queue:");
scanf("%d",&n);
if(n>10)
{
printf(" entered value exeed the limit of queue..");
getch();
exit(0);
}
printf("n enter element of queue..");
for(i=0;i<=n;i++)
{
scanf("%d",&que[i]);
front=0;
rear=rear+1 ;
}
printf("circular queue is..");
for(i=0;i<=n-1;i++)
printf("t%d",que[i]);
max=10;
printf("nn enter the item to be insereted :");
scanf("%d",&item);
if(front==0 && rear==(max-1)||front==rear+1)
{
printf("queue is full overflow!!");
getch();
exit(0);
}
if(front==-1)
{
front=0;
rear=0;
}
else
{
if(rear==max-1)
rear=0;
else
rear=rear+1;
}
n=n+1;
que[rear]=item;
printf("nitem is insereted at rear end..");
printf("nn circular queue after inserted");
for(i=0;i<=n-1;i++)
printf("t%d",que[i]);
getch();
}
OUTPUT:-
13.Merge two array.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr1[50],arr2[50],size1,size2,size,i,j,k,merge[100];
cout<<"enter array 1 size:";
cin>>size1;
cout<<"enter array 1 element:";
for(i=0;i<size1;i++)
{
cin>>arr1[i];
}
cout<<"enter array 2 size:";
cin>>size2;
{
cin>>arr2[i];
}
for(i=0;i<size1;i++)
{
merge[i]=arr1[i];
}
size=size1+size2;
for(i=0,k=size1;k<size&&i<size2;i++,k++)
{
merge[k]=arr2[i];
}
cout<<"now the new array after merging is:n";
for(i=0;i<size;i++)
{
cout<<merge[i]<<" ";
}
getch();
}
OUTPUT:-
14.Converting from infix to postfix notation.
#include<stdio.h>
char stack[20];
int top=-1;
void push(char x)
{
stack[++top]=x;
}
char pop()
{
if(top==-1)
return 1;
else
return stack[top--];
}
int priority(char x)
{
if(x=='(')
return 0;
if(x=='+'||x=='-')
return 1;
if(x=='*'||x=='/')
return 2;
}
main()
{
charexp[20];
char *e,x;
printf("enter the expression::");
scanf("%s",exp);
e=exp;
while(*e!='0')
{
if(isalnum(*e))
printf("%c",*e);
else if(*e=='(')
push(*e);
else if(*e==')')
{
while(int x=pop()) !='(')
printf("%c",x);
}
else
{
while(priority(stack[top])>=priority(*e))
printf("%c",pop());
push(*e);
}
e++;
}
while(top!=-1)
{
printf("%c",pop());
}
getch();
return;;
}
Output:-
Enter the exepression:a+b
ab+

More Related Content

What's hot

Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresLakshmi Sarvani Videla
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C LanguageRAJWANT KAUR
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointersSushil Mishra
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)vinay arora
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
Mcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singhMcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singhDIVYA SINGH
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using cArghodeepPaul
 
Network security
Network securityNetwork security
Network securitybabyangle
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diplomamustkeem khan
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 

What's hot (20)

Cpds lab
Cpds labCpds lab
Cpds lab
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Daa practicals
Daa practicalsDaa practicals
Daa practicals
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
C programs
C programsC programs
C programs
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
programs
programsprograms
programs
 
Ds program-print
Ds program-printDs program-print
Ds program-print
 
C programs
C programsC programs
C programs
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
C++ file
C++ fileC++ file
C++ file
 
Mcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singhMcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singh
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
Network security
Network securityNetwork security
Network security
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 

Similar to Programs

Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shortingargusacademy
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
Data structure output 1
Data structure output 1Data structure output 1
Data structure output 1Balaji Thala
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C CodeSyed Ahmed Zaki
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligenceAditya Sharma
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)Ankit Gupta
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language 9096308941
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignmentsreekanth3dce
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfHIMANSUKUMAR12
 
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxMerge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxscroghamtressie
 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdfsowmya koneru
 

Similar to Programs (20)

Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Ds
DsDs
Ds
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
C programs
C programsC programs
C programs
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Data structure output 1
Data structure output 1Data structure output 1
Data structure output 1
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
1D Array
1D Array1D Array
1D Array
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
Array list
Array listArray list
Array list
 
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxMerge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdf
 
week-14x
week-14xweek-14x
week-14x
 

Recently uploaded

Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...
Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...
Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...amitlee9823
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证tufbav
 
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...amitlee9823
 
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
SM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdfSM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdfStefanoBiamonte1
 
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证tufbav
 
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...MOHANI PANDEY
 
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证ehyxf
 
Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)amitlee9823
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammamahmedjiabur940
 
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...gajnagarg
 
Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...gajnagarg
 
Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...gajnagarg
 
Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...
Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...
Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...amitlee9823
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...Pooja Nehwal
 

Recently uploaded (20)

Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...
Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...
Vip Mumbai Call Girls Kalyan Call On 9920725232 With Body to body massage wit...
 
CHEAP Call Girls in Vinay Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Vinay Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Vinay Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Vinay Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
 
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...
 
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
 
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
 
SM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdfSM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdf
 
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
 
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
 
CHEAP Call Girls in Mayapuri (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Mayapuri  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Mayapuri  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Mayapuri (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
 
Critical Commentary Social Work Ethics.pptx
Critical Commentary Social Work Ethics.pptxCritical Commentary Social Work Ethics.pptx
Critical Commentary Social Work Ethics.pptx
 
Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Arekere ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
 
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
 
Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Shillong Escorts ☎️9352988975 Two shot with one girl...
 
Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Bhiwandi Escorts ☎️9352988975 Two shot with one girl...
 
Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...
Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...
Hosa Road Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ban...
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
 

Programs

  • 1. • Find the factorialof a number. #include<iostream.h> #include<conio.h> void main() { intn,fact; int rec(int); clrscr(); cout<<"enter the number:-"; cin>>n; fact=rec(n); cout<<endl<<"factorial results are::"<<fact<<endl; getch(); } rec(int x) { int f; if(x==1) return(x); else f=x*rec(x-1); return(f); } OUTPUT:-
  • 2. 2. Insertthe elementinto an array. #include<stdio.h> #include<conio.h> #include<process.h> intarr[10],n,i,j,k,item,loc; void main() { clrscr(); printf("n enter the size of array"); scanf("%d",&n); if(n>10) { printf("n entered value exceed the limit of array"); getch(); } printf("n enter array element .."); for(i=1;i<=n;i++) scanf("%d",&arr[i]); printf("enter the element to inserted..."); scanf("%d",&item); for(j=n-1;j<=loc;j++) arr[j+1]=arr[j]; arr[loc]=item; printf("n array after insertion.."); k=0; while(k<=n) { printf("n"); printf("%d",arr[k]); k=k+1; } getch(); } OUTPUT:-
  • 3. 3. Deleting the elements from array. #include<stdio.h> #include<conio.h> void main() { int a[20],n,k,item,i; void delete(int a[],int *,int k); clrscr(); printf("enter no. of element="); scanf("%d",&n); for(i=0;i<n;i++) { printf("n enter element a[%d]=",i); scanf("%d", &a[i]); } printf("enter position of element you want to be deleted:"); scanf("%d",&k); delete(a,&n,k-1); printf("element after deletion:n"); for(i=0;i<n;i++) printf("%d",a[i]); getch(); } void delete(int a[],int *size1,int k) { int n1=*size1; inti; for(i=k;i<n1-2;i++) a[i]=a[i+1]; *size1=*size1-1; } OUTPUT:-
  • 4. 4.Traversing the elements in array. #include<stdio.h> #include<conio.h> void main() { void print1(long[]); long profit[5]={50000,10000,20000,75000,30000}; clrscr(); print1(profit); getch(); } void print1(long profit[]) { inti; intst_year=1950; printf("yearttprofitn"); printf("--------n"); for(i=0;i<5;i++) printf("%dtt%dn",st_year +i,profit[i]); } Output:-
  • 5. 5. Program for the bubble sort. #include<iostream.h> #include<conio.h> void main() { intarr[5]; cout<<"enter 5 number randomly:"; for(inti=0;i<5;i++) { cin>>arr[i]; } cout<<"ninput array is:"; for(int j=0;j<5;j++) { cout<<"n value at"<<j<<"index:"<<arr[j]; } int temp; for(int i2=0;i2<4;i2++) { for(int j=0;j<4;j++) { if(arr[j]>arr[j+1]) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } }
  • 6. cout<<"nsorting array is:"; for(int i3=0;i3<5;i3++) { cout<<"n value at"<<i3<<"index:"<<arr[i3]; } getch(); } OUTPUT:- 6. Selection sort. #include<stdio.h> #include<conio.h> int m; int minimum(int *,int); voidselect_sort(int *); int minimum(int a[],inti) { intmini,loc; mini=a[i]; loc=i; while(i<m) { if(mini>a[i+1]) { mini=a[i+1]; loc=i+1; } i++; } return(loc); } voidselect_sort(int a[]) { inttemp,i=1, loc; for(i=1;i<m;i++)
  • 7. { loc=minimum(a,i); temp=a[i]; a[i]=a[loc]; a[loc]=temp; } } void display(int a[]) { inti; for(i=0;i<m;i++) printf("ntt list[%d]=%d",i,a[i]); } void main() { int a[20]; inti; clrscr(); printf("n how many element you want to insert:"); scanf("%d",&m); printf("n enter the element"); for(i=0;i<m;i++) { printf("n a[%d]=",i); scanf("%d",&a[i]); } printf("ntt"); printf("nt list before sorting:n"); display(a); select_sort(a); printf("nnt"); printf("nt list after sorting:"); printf("nt...."); display(a); getch(); } OUTPUT:-
  • 8. 7.Insertion sort. #include<stdio.h> #include<conio.h> int m; voidinsertion_sort(int *); void display(int *); voidinsertion_sort(int a[]) { intele,i; for(i=1;i<m;i++) { ele=a[i]; while(ele<a[i-1]&&i>0) { a[i]=a[i-1];
  • 9. i--; } a[i]=ele; } } void display(int a[]) { inti; for(i=0;i<m;i++) printf("nt list[%d]=%d",i,a[i]); } void main() { int a[20];inti; clrscr(); printf("n how many element you want to inert :"); scanf("%d",&m); printf("n enter the element :"); for(i=0;i<m;i++) { printf("n a[%d]=",i); scanf("%d",&a[i]); } printf("nt.."); printf("nt list before sorting:"); printf("nt..."); display(a); insertion_sort(a); printf("ntt..."); printf("nt...."); display(a); getch(); } OUTPUT:-
  • 10. 8.Linear search. #include<stdio.h> #include<conio.h> void main() { intarr[10],n,i,item,loc; clrscr(); printf("enter the size of array:"); scanf("%d",&n); printf("n enter array element..."); for(i=1;i<=n;i++) { scanf("%d",&arr[i]); } printf("enter the element to be search"); scanf("%d",&item); for(i=1;i<=n;i++) if(arr[i]==item) { loc=i; printf("n element found of location %d",loc); } getch(); } OUTPUT:-
  • 11. 9.Binary search. #include<stdio.h> #include<conio.h> #include<process.h> #define true 1 #define false 0 intarr[10],n,i,item,loc,flag=0,low,high,middle; void main() { clrscr(); printf("enter the size of array:"); scanf("%d",&n); if(n>10) { printf("entered value exceed the limit of array"); getch(); exit(0); } printf("n enter array element .."); for(i=1;i<=n;i++) scanf("%d",&arr[i]); printf("enter the element to be searched"); scanf("%d",&item); low=0; high=n-1; while(low<=high && flag==0) middle=(low+high)/2; if(item<arr[middle])
  • 12. high=middle-1; else if(item>arr[middle]) low=middle+1; { flag=1; loc=middle; } } if (flag==1) { printf("n element found at location %d",loc); } else { printf("n element not found..."); getch(); } OUTPUT:-
  • 13. 10. Enter the elementinto an array. #include<stdio.h> #include<conio.h> void main() { intn,i,k,lb,ub,a[10]; clrscr(); printf("n enter the total no. of element of array:"); scan("%d",&n); printf("nenter the element in array:"); for(i=1;i<=n;i++) { printf("element no.[%d] is ",i); scanf("%d",a[i]); } lb=1; ub=n; k=lb; printf("nn"); while(k<=ub) { printf("element no.[%d] is %dn",k,a[k]); k=k+1; } getch(); } OUTPUT:-
  • 14. 11.Pushoperation in a stack. #include<stdio.h> #include<conio.h> #define max 100 int top=-1; int flag=0; int stack[max]; void push(int *,int); int pop(int *); void display(int *); void push(int stack[],int item) { if(top==(max-1)); flag=0; { flag=1; top++; stack[top]=item; } } int pop(int stack[]) { int item; if(top<0); { item=0; flag=0; } { flag=1; item=stack[top]; top--; } return(item); } void display(int stack[]) { inti; if(top==-1) { printf("nntt stack is empty"); } else { for(i=top;i>=0;i--) printf("nntt stack[%d]=%d",i,stack[i]); } }
  • 15. void main() { intn,i,item,f=1; clrscr(); printf("nntt"); printf("ntt stack is empty"); printf("nn push some item on to stack"); printf("nn how many item you want to push:"); scanf("%d",&n); for(i=1;i<=n;i++) { printf("nn enter item:"); push(stack,item); if(flag) { printf("nntt"); printf("ntt"); printf("nntt stack after operation:n"); printf("ntt"); display(stack); } else { printf("nntt"); printf("ntt stack is full"); printf("ntt"); } } while(f==1) { item=pop(stack); if(flag) { printf("nn the popod item is %d",item); printf("nntt stack after pop opreation:n"); printf("ntt"); display(stack); } else { printf("nntt"); printf("nntt stack is empty"); printf("nnttt"); } printf("nnpop again(1/0):"); scanf("%d", &f); } getch(); }
  • 16. OUTPUT:- 12.Insertitem into queue. #include<stdio.h> #include<conio.h> #include<process.h> intque[10],i,max, item,front=-1,rear=-1,n; void main() { clrscr(); printf("enter size of cicular queue:"); scanf("%d",&n); if(n>10) { printf(" entered value exeed the limit of queue.."); getch(); exit(0); } printf("n enter element of queue.."); for(i=0;i<=n;i++) { scanf("%d",&que[i]); front=0; rear=rear+1 ; } printf("circular queue is.."); for(i=0;i<=n-1;i++)
  • 17. printf("t%d",que[i]); max=10; printf("nn enter the item to be insereted :"); scanf("%d",&item); if(front==0 && rear==(max-1)||front==rear+1) { printf("queue is full overflow!!"); getch(); exit(0); } if(front==-1) { front=0; rear=0; } else { if(rear==max-1) rear=0; else rear=rear+1; } n=n+1; que[rear]=item; printf("nitem is insereted at rear end.."); printf("nn circular queue after inserted"); for(i=0;i<=n-1;i++) printf("t%d",que[i]); getch(); } OUTPUT:-
  • 18. 13.Merge two array. #include<iostream.h> #include<conio.h> void main() { clrscr(); int arr1[50],arr2[50],size1,size2,size,i,j,k,merge[100]; cout<<"enter array 1 size:"; cin>>size1; cout<<"enter array 1 element:"; for(i=0;i<size1;i++) { cin>>arr1[i]; } cout<<"enter array 2 size:"; cin>>size2; { cin>>arr2[i]; } for(i=0;i<size1;i++) { merge[i]=arr1[i]; } size=size1+size2; for(i=0,k=size1;k<size&&i<size2;i++,k++) { merge[k]=arr2[i]; } cout<<"now the new array after merging is:n"; for(i=0;i<size;i++) { cout<<merge[i]<<" ";
  • 19. } getch(); } OUTPUT:- 14.Converting from infix to postfix notation. #include<stdio.h> char stack[20]; int top=-1; void push(char x) { stack[++top]=x; } char pop() { if(top==-1) return 1; else return stack[top--]; } int priority(char x) { if(x=='(') return 0; if(x=='+'||x=='-') return 1; if(x=='*'||x=='/') return 2; } main() { charexp[20]; char *e,x; printf("enter the expression::"); scanf("%s",exp); e=exp; while(*e!='0')
  • 20. { if(isalnum(*e)) printf("%c",*e); else if(*e=='(') push(*e); else if(*e==')') { while(int x=pop()) !='(') printf("%c",x); } else { while(priority(stack[top])>=priority(*e)) printf("%c",pop()); push(*e); } e++; } while(top!=-1) { printf("%c",pop()); } getch(); return;; } Output:- Enter the exepression:a+b ab+