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

What is a loop?

959


Do you know the difference between exit() and _exit() function in c?

1012


How do you determine the length of a string value that was stored in a variable?

1078


what are bit fields in c?

1596


List the difference between a "copy constructor" and a "assignment operator"?

957


Why isnt there a numbered, multi-level break statement to break out

994


What is a global variable in c?

951


Is it possible to use curly brackets ({}) to enclose single line code in c program?

1256


What are the types of data structures in c?

1081


Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?

2625


What is restrict keyword in c?

1049


Write a program to check palindrome number in c programming?

961


Explain a pre-processor and its advantages.

1068


Explain what is the concatenation operator?

1105


Where are local variables stored in c?

981