SlideShare une entreprise Scribd logo
1  sur  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+

Contenu connexe

Tendances

C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
vinay arora
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
Ankit Dixit
 

Tendances (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
 

Similaire à Programs

Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
Er Ritu Aggarwal
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
Aditya Sharma
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
sreekanth3dce
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
HIMANSUKUMAR12
 

Similaire à 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
 

Dernier

一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
wpkuukw
 
一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证
一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证
一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证
wpkuukw
 
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
uodye
 
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
drmarathore
 
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
ehyxf
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
tufbav
 
怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证
怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证
怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证
ehyxf
 
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
oopacde
 
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
ayoqf
 
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
tufbav
 
Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...
gajnagarg
 

Dernier (20)

一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
 
一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证
一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证
一比一定(购)UNITEC理工学院毕业证(UNITEC毕业证)成绩单学位证
 
Mass storage systems presentation operating systems
Mass storage systems presentation operating systemsMass storage systems presentation operating systems
Mass storage systems presentation operating systems
 
Critical Commentary Social Work Ethics.pptx
Critical Commentary Social Work Ethics.pptxCritical Commentary Social Work Ethics.pptx
Critical Commentary Social Work Ethics.pptx
 
🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...
🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...
🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...
 
Call Girls Amethi 9332606886 HOT & SEXY Models beautiful and charming call g...
Call Girls Amethi  9332606886 HOT & SEXY Models beautiful and charming call g...Call Girls Amethi  9332606886 HOT & SEXY Models beautiful and charming call g...
Call Girls Amethi 9332606886 HOT & SEXY Models beautiful and charming call g...
 
Hilti's Latest Battery - Hire Depot.pptx
Hilti's Latest Battery - Hire Depot.pptxHilti's Latest Battery - Hire Depot.pptx
Hilti's Latest Battery - Hire Depot.pptx
 
Vashi Affordable Call Girls ,07506202331,Vasai Virar Charming Call Girl
Vashi Affordable Call Girls ,07506202331,Vasai Virar Charming Call GirlVashi Affordable Call Girls ,07506202331,Vasai Virar Charming Call Girl
Vashi Affordable Call Girls ,07506202331,Vasai Virar Charming Call Girl
 
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
 
Point of Care Testing in clinical laboratory
Point of Care Testing in clinical laboratoryPoint of Care Testing in clinical laboratory
Point of Care Testing in clinical laboratory
 
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
 
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
 
Guwahati Escorts Service Girl ^ 9332606886, WhatsApp Anytime Guwahati
Guwahati Escorts Service Girl ^ 9332606886, WhatsApp Anytime GuwahatiGuwahati Escorts Service Girl ^ 9332606886, WhatsApp Anytime Guwahati
Guwahati Escorts Service Girl ^ 9332606886, WhatsApp Anytime Guwahati
 
怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证
怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证
怎样办理伍伦贡大学毕业证(UOW毕业证书)成绩单留信认证
 
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
 
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
 
LANDSLIDE MONITORING AND ALERT SYSTEM FINAL YEAR PROJECT BROCHURE
LANDSLIDE MONITORING AND ALERT SYSTEM FINAL YEAR PROJECT BROCHURELANDSLIDE MONITORING AND ALERT SYSTEM FINAL YEAR PROJECT BROCHURE
LANDSLIDE MONITORING AND ALERT SYSTEM FINAL YEAR PROJECT BROCHURE
 
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
 
Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Palghar [ 7014168258 ] Call Me For Genuine Models W...
 

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+