Archive for data structures in c

You are browsing the archives of data structures in c.

Important programs in c language part-IV

/*insert subtree*/

#include<stdio.h>
#include<conio.h>
struct rec
{
long num;
struct rec *left;
struct rec *right;
};
struct rec *tree=NULL;
struct rec *insert(struct rec *tree,long num);
void *exchange(struct rec *tree);
struct rec *temp;
void main()
{
struct rec *tree=NULL;
int choice;
long digit;
do
{
choice=select();
switch(choice)
{
case 1: puts("Enter integer: To quit enter [...]

Important programs in c language part-II

/*Deletion in the Array*/

#include<stdio.h>
#include<conio.h>
int i,n;
main()
{
int a[100],pos;
void delete(int a[],int,int);
clrscr();
printf("How many elements in the array\n");
scanf("%d",&n);
printf("Enter the element of the array\n");
for(i=0;i<=n-1;i++)
scanf("%d",&a[i]);
printf("On which postion element do you want delete\n");
scanf("%d",&pos);
delete(a,pos,n);
getch();
}
void delete(int a[],int pos,int n)
{
int j,item;
item=a[pos];
for(j=pos;j<=n-1;j++)
{
a[j]=a[j+1];
}
n=n-1;
for(i=0;i<=n-1;i++)
printf("%d\n",a[i]);
}

/*Factorial*/

#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int n,result;
clrscr();
printf("Enter the number");
scanf("%d",&n);
result=fact(n);
printf("\n The factorial of %d is %d",n,result);
getch();
}
int fact(int x)
{
int f;
if(x==1)
[...]