Wednesday, 6 August 2014

#include<stdio.h>
int main()
{
    int a[20],ele,num,i;
    printf("\n enter no of element");
    scanf("%d",&num);
    printf("\n enter the values");
    for(i=0;i<num;i++)
    {
                      scanf("%d",&a[i]);
                     
                      }
                      /* searching*/
                      printf( "enter the element to be search");
                      scanf("%d",&ele);
                      /* search start from zero location*/
                      i=o;
                      while(i<num && ele != a[i])
                      {
                                  i++;
                                  }
                                  if(i<num)
                                  {
                                           printf("number found at location");
                                         
                                           }
                                           else
                                           {
                                               printf("no. not found");
                                           }
return o;
}
  
                                      OUTPUT
Enter the number of elements to be searched : 5
Enter the numbers : 45
64
12
78
91
Enter the element to be searched : 64
  64 is present in location 2

1 comment:

  1. Error:-
    its i=0 and return 0, not 'o'.
    Some Improvement
    put header file #include
    and before return 0, write getch();, means it will hold the screen till you wont enter any character so that user can read the output.

    ReplyDelete

Note: only a member of this blog may post a comment.