I am having two minor problems in this code but i am unable to get them. i have mentioned on the places the compiler is giving error.There are two of them given below:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define SIZE 100
int count;
void menu(void);
void input(int[]);
void print(int[]);
void insert(int[]);
void delete_element(int arr[]);
void search(int arr[]);
void main(void)
{
int arr[SIZE];
char choice;
while(1)
{
menu();
choice=getche();
switch (choice)
{
case'1':input(arr);break;
case'2':delete_element(arr);break;
case'3':insert(arr);break;
case'4':print(arr);break;
case'5':search(arr);break;
case'6':exit(0);//from stdlib.h
default:printf("Enter valid choice!");
}
getch();
}
void print(int arr[])
{ // says declaration syntax error here
int i;
for(i=0;i<count ;i++)
printf("element is %d",arr[i]);
}
void input(int arr[])
{
if(count<SIZE)
for(count=0; ;count++)
{
printf("Enter element %d:",i+1);
scanf("%d"&arr[i]);
if(arr[count]==0)
{
count--;
break;
}
}
}
void insert(int arr[])
{
int i,value,index;
if(count==SIZE)
printf("Not enough space to perform insertion");
else
{
printf("Enter value and index:");
scanf("%d",&value,&index);
for(i=index;i<=LEN;i++)
{
arr[i]=arr[i-1];
}
arr[index]=value;
count++;
printf("insertion succesful");
}
}
void delete_element(int arr[])
{
int index,i;
if(count==0)
{
printf("Empty array");
}
else
{
printf("Enter Index:");
scanf("%d",&index);
for(i=index;i<LEN;i++)
{
arr[i]=arr[i+1]
}
count--;
printf("Delete succesful.");
}
}
void search(int arr[])
{
int value,flag=0,i;
printf("Enter value:");
scanf("%d",&value);
for(i=0;i<count;i++)
{
if(arr[i]==value)
{
printf("Value %d is found at index:",value,index);
flag=i;
}
}
if(!flag)
printf("Value not found");
printf("Search Complete");
}
} // declaration missing ; here