Skip to content

Instantly share code, notes, and snippets.

@gallirohik
Created February 25, 2018 17:43
Show Gist options
  • Save gallirohik/e4428723e788ef79d81cdff5d4df8b2b to your computer and use it in GitHub Desktop.
Save gallirohik/e4428723e788ef79d81cdff5d4df8b2b to your computer and use it in GitHub Desktop.
Missed number in an array
#include <stdio.h>
#include <stdlib.h>
int lsearch(int *arr,int length)
{
int i;
for(i=0;i<length;i++)
if(arr[i]==0)return i+1;
}
int main()
{
int arr[50]={0},n,i,buffer;
printf("Enter size of the array:");
scanf("%d",&n);
for(i=0;i<n-1;i++)
{
scanf("%d",&buffer);
arr[buffer-1]=1;
}
printf("Missed Element is:%d",lsearch(arr,n));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment