this is menu base program declaration error [on hold]
Declaration error plz how can i remove this error in bubble sort .....
include
include
include
include
define MAX 50
large_no(); small_no(); secondbeg(); secondsmall(); search_no(); void
bubble_sort(); void inseration_sort(int a[]); void merge_sort(int a[],int
[], int []); void merge_array(int a[],int [],int [],int []); void
insert(); void delet(); void display(); queue_using(); int queue[MAX]; int
rear= -1,front= -1; push_pop(); void push(); void pop(); void display();
int stack[MAX]; int item,top;
void main() { clrscr();
int
largest,smallest,s_l,s_s,search,choice,b,s,m,q,opt,item,ch,size,j=0,big,secondbig,small,secondsmall;
int a[7],i,n,beg,end;
printf("________________________________________________________________________________");
printf("\t MENU \n);
printf(________________________________________________________________________________);
printf(\n(A) Array program list \n);
printf(\n\t\t (1)==== Largest no\n \t\t (2)==== Smallest no\n \t\t (3)====
2nd largest no\n\t\t (4)==== 2nd smallest no\n\t\t (5)==== Searching in
array);
scanf(%d,amp;largest,%d,smallest,%d,s_l,%d,s_s,%d,search);
printf(\n\t\t---------------------------------);
printf(\n\ (B) ******** SORTING TYPES IN ARRAY********\n);
printf(\n\t\t (6)==== Bubble sort \n\t\t (7)==== inseration sort\n\t\t
(8)==== Merge sort);
scanf(%d,b,%d,s,%d,m,%d,q);
printf(\n (C) ******** Queue using array********\n);
printf(\n\t\t (9)=== Queue program);
scanf(%d,queue);
printf(\n\t\t---------------------------------);
printf(\n\t\t (10)=== Push And Pop);
scanf(%d,push_pop);
printf(\n\t\t---------------------------------);
printf(\n\t\t (11)=== Infix to Postfix convert program);
printf(\n\t\tEnter your choice);
scanf(%d,amp;choice);
{
switch(choice)
{
case 1: large_no();
{
printf(\n\t\t******YOU HAVE SELECT TO FIND A LARGEST NO******
\n\n\t\tEnter the elements of array);
for(i=0;ilt;6;i++)
scanf(%d,amp;a[i]);
largest=a[0];
for(i=0;ilt;6;i++)
if(a[i] gt; largest)
largest=a[i];
printf(\n\tlargest no is %d,largest);
}
break;
case 2: small_no();
{
printf(\n\t******YOU HAVE SELECT TO FIND A SMALLEST NO******
\n\n\t\tEnter the elements of array);
for(i=0;ilt;6;i++)
scanf(%d,amp;a[i]);
smallest=a[0];
for(i=0;ilt;6;i++)
if(a[i] lt; smallest)
smallest=a[i];
printf(\n\tsmallest no is %d,smallest);
}
break;
case 3:secondbeg;
{
printf(Enter the size of the array: );
scanf(%d,amp;size);
printf(Enter %d elements in to the array: , size);
for(i=0;ilt;size;i++)
scanf(%d,amp;a[i]);
big=a[0];
for(i=1;ilt;size;i++)
{
if(biglt;a[i])
{
big=a[i];
j = i;
}
}
secondbig=a[size-j-1];
for(i=1;ilt;size;i++)
{
if(secondbig lt;a[i] amp;amp; j != i)
secondbig =a[i];
}
printf(Second biggest: %d, secondbig);
}
break;
case 4:secondsmall;
{
printf(Enter the size of the array: );
scanf(%d,amp;size);
printf(Enter %d elements in to the array: , size);
for(i=0;ilt;size;i++)
scanf(%d,amp;a[i]);
small=a[0];
for(i=1;ilt;size;i++)
{
if(smallgt;a[i])
{
small=a[i];
j = i;
}
}
secondsmall=a[size-j-1];
for(i=1;ilt;size;i++)
{
if(secondsmall gt;a[i] amp;amp; j != i)
secondsmall =a[i];
}
printf(Second smallest: %d, secondsmall);
}
break;
case 5: search_no();
{
printf(\n\t******YOU HAVE SELECT OPTION TO FIND A SEARCH NO******
\n\n\t\tEnter the elements of array);
for(i=0;ilt;=6;i++)
scanf(%d,amp;a[i]);
printf(Enter the element to search);
scanf(%d,amp;item);
if(item==a[i])
printf(Item is found);
}
case 6: bubble_sort();
{
printf(\n\t******YOU HAVE SELECT A BUBBLE SORT OPTION******
\n\n\t\tEnter the elements of array);
for(i=0;ilt;6;i++)
scanf(%d,amp;a[i]);
bubble_sort();
printf(after sorting);
for(i=0;ilt;6;i++)
printf(%d,a[i]);
getch();
}
void bubble_sort()
{
int j,k,temp;
for(j=0;jlt;6;j++)
for(k=0;klt;(6-1)-j;k++)
if(a[k] gt; a[k+1])
{
temp=a[k];
a[k]=a[k+1];
a[k+1]=temp;
}
case 7: inseration_sort();
{
printf(\n\t******YOU HAVE SELECT A INSERATION OPTION ******
\n\n\t\tEnter the elements of array);
for(i=0;ilt;6;i++)
scanf(%d,amp;a[i]);
inseration_sort(a);
printf(after sort);
for(i=0;ilt;6;i++)
printf(%d,a[i]);
getch();
}
void inseration_sort(int a[])
{
int j,k,temp;
for(j=1;jlt;6;j++)
{
temp=a[j];
k=j-1;
while(kgt;=0 amp;amp; (a[k]gt;temp))
{
a[k+1]=a[k];
k--;
}
a[k+1]=temp;
}
}
case 8: merge_sort();
{ printf(\n\t******YOU HAVE SELECT FIND THE MERGE SORT******
\n\n\t\tEnter the elements of array);
scanf(%d,amp;n);
printf(enter the element of array);
for(i=0;ilt;n;i++)
scanf(%d,amp;a[i]);
merge_sort(a,0,n-1);
printf(ather merge sorting);
for(i=0;ilt;n;i++)
printf(%d, a[i]);
getch();
}
void merge_sort(int a[],int beg, int end)
{
int mid;
if(beg lt; end)
{
mid=(beg+end)/2;
merge_sort(a,beg,mid);
merge_sort(a,mid+1,end);
merge_array(a,beg,mid,end);
}
}
void merge_array(int a[],int beg,int mid,int end)
{
int i,num,temp,j,k,b[10];
for(i=beg;ilt;=end;i++)
b[i]=a[i];
i=beg;
j=mid+1;
k=beg;
while((ilt;=mid) amp;amp; (jlt;=end))
{
if(b[i]lt;=b[j])
{
a[k]=b[i];
i++;
k++;
}
else
{
a[k]=b[j];
j++;
k++;
}
}
if(ilt;=mid)
{
while(ilt;=mid)
{
a[k]=b[i];
i++;
k++;
}
}
else
{
while(jlt;=end)
{
a[k]=b[j];
j++;
k++;
}
}
}
}
case 9:queue_using;
{
do
{ printf(\n\t******YOU HAVE SELECTED OPTION TO FIND THE
QUEUE USING IN ARRAY PROGRAM****** );
printf(\n\t\t (1)=== insert \n\t\t (2)===Delete \n\t\t
(3)===Display \n\t\t (4)===Exit);
printf(\n\t\t enter your choice);
scanf(%d,amp;ch);
switch (ch)
{
case 1:
insert();
break;
case 2:
delet();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf(\n\t\tinvalid Entry!.. please Try Again..);
}
}while(1);
}
void insert()
{
if(rear==MAX-1)
printf(\n\n\t\t queue is full);
else
{
printf(\n\n\t\t enter item);
scanf(%d,amp;item);
if(rear==-1 amp;amp; front==-1)
{
rear=0;
front=0;
}
else
rear++;
queue[rear]=item;
printf(\n\n\t\t item inserted: %d,item);
}
}
void delet()
{
if(front== -1)
printf(\n\n\t\t queue is empty);
else
{
item=queue[front];
if(front== rear)
{
front= -1;
rear= -1;
}
else
front++;
printf(\n\n\t\t item is deleted: %d,item);
}
}
void display()
{
int i;
if(front== -1)
printf(\n\n\t\t queue is empty);
else
{
printf(\n\n\t\t);
for(i=front;ilt;=rear;i++)
printf( %d,queue[i]);
}
}
case 10:push_pop();
{
do
{ printf(\n\t******YOU HAVE SELECTED PUSH AND POP
PROGRAM****** \n\n\t\tEnter the elements of array);
printf(\n\t\t 1.push \n\t\t 2.pop \n\t\t 3.Display \n\t\t
4.Exit);
printf(\n\t\t enter your choice);
scanf(%d,amp;ch);
switch (ch)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf(\n\t\tinvalid enty! .... please try again ...);
}
}while(1);
}
void push()
{
int i;
if(top==MAX)
printf(\n\n\t\t stack is full);
else
{
printf(\n\n\t\t enter item);
scanf(%d,amp;item);
top++;
stack[top]=item;
printf(\n\n\t\t item inserted: %d,item);
}
}
void pop()
{
if(top== 0)
printf(\n\n\t\t stack is empty);
else
{
item=stack[top];
top=top-1;
printf(\n\n\t\t item is deleted: %d,item);
}
}
void display()
{
int i;
if(top== 0)
printf(\n\n\t\t queue is empty);
else
{
printf(\n\n\t\t);
for(i=top;igt;=0;i--)
printf( %d,stack[i]);
}
}
/code/pre
pgetch();
}
}
}/p
No comments:
Post a Comment