Error problem

Discussion in 'C' started by answerme, Mar 11, 2008.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    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);
    }	
     
  2. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    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);
    }	
    
    
    
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice