0
1.2kviews
Write a program to search a number within the array.
1 Answer
0
2views
#include<stdio.h>
 voidmain(){
   inta[30],ele,num,i;
   printf("\nEnter no of elements :");
   scanf("%d",&num);
   printf("\nEnter the values :");
   for(i=0;i<num;i++){
      scanf("%d",&a[i]);
   }
   //Read the element to be searched
   printf("\nEnter the elements to be searched :");
   scanf("%d",&ele);

   //Search starts from the zeroth location
   i=0;
   while(i<num&&ele!=a[i]){
      i++;
   }
   //If i < num then Match found
   if(i<num){
      printf("Number found …

Create a free account to keep reading this post.

and 5 others joined a min ago.

Please log in to add an answer.