Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Given an array of numbers, except for one number all the
others occur twice. Give an algorithm to find that number
which occurs only once in the array.

Answer Posted / guest

int arr[n]; //n' numbers

for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
{ if ( (a[i]==a[j])&&i!=j ) break; //ITS NOT THE NUM
if ( (a[i]!=a[j])&&j==n-1) return i; //IT IS!!
return -1; //IF THERE IS NO SUCH NUMBER...

Is This Answer Correct ?    3 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I copy files?

1009


Who developed c language?

1050


how can I convert a string to a number?

1045


What is extern storage class in c?

955


Explain what does the format %10.2 mean when included in a printf statement?

1309


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1919


difference between object file and executable file

6658


What does 1f stand for?

1103


What is the purpose of & in scanf?

1026


What are multidimensional arrays?

1079


Explain what are the standard predefined macros?

1088


Why is %d used in c?

969


What are the two forms of #include directive?

1115


What is realloc in c?

1030


What are run-time errors?

1068