Hye iam facing an error i.e. Error 6 error C2143: syntax error : missing ')' before 'type' Error 7 error C2059: syntax error : ') CODE is Code: #include<stdio.h> #define MAX 10 int a[MAX]; //int search_no(int search); main() { int n,i,search,pos; int ch,x; while(1) { printf("\n Enter The Choice"); printf("\n1.Input"); printf("\n2.Display"); printf("\n3.Search"); printf("\n .Exit"); scanf("%d",&ch); switch(ch) { case 1: printf("\nEnter the number"); scanf("%d",&n); x=input(n); break; case 2: printf("Display number\n"); for(i=0;i<=n-1;i++) { printf("%d\n",a[i]); } break; case 3:printf("Enter the number to search\n"); [B]scanf("%d",&search); pos=searchno(int search);[/B] //this is where error is coming break; default:exit(); } } } input(int n) { int i; printf("\n Enter the element"); for(i=0;i<=n-1;i++) scanf("%d",&a[i]); } int searchno(int search) { int i,n; for(i=0;i<=n-1;i++) { if(search==a[i]) return(i+1); }return(0); }
Correct code is Code: #include<stdio.h> #include<stdlib.h> #define MAX 10 int a[MAX]; void input(int); int search_no(int ); main() { int n,i,search,pos; int ch; while(1) { printf("\n Enter The Choice"); printf("\n1.Input"); printf("\n2.Display"); printf("\n3.Search"); printf("\n .Exit"); scanf("%d",&ch); switch(ch) { case 1: printf("\nEnter the number"); scanf("%d",&n); input(n);//no return break; case 2: printf("Display number\n"); for(i=0;i<=n-1;i++) { printf("%d\n",a[i]); } break; case 3:printf("Enter the number to search\n"); scanf("%d",&search); pos=search_no(search); //remove int break; default: exit(0); } } } void input(int n) { int i; printf("\n Enter the element"); for(i=0;i<=n-1;i++) scanf("%d",&a[i]); } int search_no(int search) { int i,n; for(i=0;i<=n-1;i++) { if(search==a[i]) return(i+1); }return(0); }