PROGRAM TO PERFORM BINARY SEARCH

/*PROGRAM TO PERFORM BINARY SEARCH*/ #include<stdio.h> #include<conio.h> void main() { int n,srch,i,j,a[10],temp,high,low=0,mid=0; clrscr(); printf(“Enter the size of array: “); scanf(“%d”,&n); printf(“Enter %d elements in the array:\n”,n); for(i=0;i<n;i++) scanf(“%d”,&a[i]); /*SORTING STARTS*/ …

PROGRAM TO PERFORM LINEAR SEARCH

/*PROGRAM TO PERFORM LINEAR SEARCH*/ #include<stdio.h> #include<conio.h> void main() { int n,srch,i,count=0,a[10]; clrscr(); printf(“Enter the size of array: “); scanf(“%d”,&n); printf(“Enter %d elements in the array:\n”,n); for(i=0;i<n;i++) scanf(“%d”,&a[i]); printf(“Elements in …

PROGRAM TO SORT A GIVEN ARRAY USING SELECTION SORT

/*PROGRAM TO SORT A GIVEN ARRAY USING SELECTION SORT*/ #include<stdio.h> #include<conio.h> void main() { int n,i,j,a[10],temp; clrscr(); printf(“Enter the size of array: “); scanf(“%d”,&n); printf(“Enter %d elements in the array:\n”,n); …

PROGRAM TO SORT A GIVEN ARRAY USING BUBBLE SORT

/*PROGRAM TO SORT A GIVEN ARRAY USING BUBBLE SORT*/ #include<stdio.h> #include<conio.h> void main() { int n,i,j,a[10],temp; clrscr(); printf(“Enter the size of array: “); scanf(“%d”,&n); printf(“Enter %d elements in the array:\n”,n); …

PROGRAM TO ADD ELEMENTS OF A MATRIX USING RECURSION

/*PROGRAM TO ADD ELEMENTS OF A MATRIX USING RECURSION*/ #include<stdio.h> #include<conio.h> void add(int b[],int,int,int); void main() { int a[15][15],b[15],i,j,m,n,q,k,sum=0,l=0; clrscr(); printf(“Enter the order of matrix\n”); scanf(“%d%d”,&m,&n); if(m==0 || n==0) { …

PROGRAM TO PRINT FIBONACCI SERIES USING RECURSION

/*PROGRAM TO PRINT FIBONACCI SERIES USING RECURSION*/ #include<stdio.h> #include<conio.h> void fib(int,int,int); void main() { int n,a=-1,b=1; clrscr(); printf(“Enter the limit of series: “); scanf(“%d”,&n); printf(“First %d terms of fibonacci series …

PROGRAM TO SHOW LARGEST OF TWO NUMBRS USING FUNCTIONS

/*PROGRAM TO SHOW LARGEST OF TWO NUMBRS USING FUNCTIONS*/ #include<stdio.h> #include<conio.h> void large(int,int); void main() { int a,b; clrscr(); printf(“Enter any two numbers: “); scanf(“%d%d”,&a,&b); large(a,b); getch(); } void large(int …

PROGRAM TO SHOW CALL BY REFERENCE

/*PROGRAM TO SHOW CALL BY REFERENCE*/ #include<stdio.h> #include<conio.h> void arper(int *,int *,int,int); void main() { int l,b,ar,per; clrscr(); printf(“Enter length and breadth of rectangle: “); scanf(“%d%d”,&l,&b); arper(&ar,&per,l,b); printf(“Area of rectangle …

PROGRAM TO SHOW CALL BY VALUE

/*PROGRAM TO SHOW CALL BY VALUE*/ #include<stdio.h> #include<conio.h> int area(int,int); int peri(int,int); void main() { int l,b,ar,per; clrscr(); printf(“Enter length and breadth of rectangle: “); scanf(“%d%d”,&l,&b); ar=area(l,b); per=peri(l,b); printf(“Area of …