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 / pushpa

int num[3];
int i,j,p=0,count_1=0,count=0,n;

n= 3;
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}


for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(num[i] == num[j])
count_1=0;
else
count++;
}
if(count == n-1)
{
printf("The number which occurs once is %d\n",num[i]);
}
count = 0;

}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is void a keyword in c?

993


What is c token?

1080


Do you know the use of fflush() function?

1072


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

2352


What is #define in c?

1057


write a program to find out prime number using sieve case?

2106


What is the difference between int main and void main?

1058


What is meant by operator precedence?

1164


Do pointers take up memory?

1167


Write a simple code fragment that will check if a number is positive or negative.

1169


What is meant by realloc()?

1168


What are formal parameters?

1131


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1479


Why can't I perform arithmetic on a void* pointer?

1111


What is else if ladder?

1031