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

Can two or more operators such as and be combined in a single line of program code?

1326


Why is a semicolon (;) put at the end of every program statement?

1051


What is the ANSI C Standard?

1231


Explain what are the advantages and disadvantages of a heap?

1053


What 'lex' does?

1123


What is meant by preprocessor in c?

975


Explain what is meant by 'bit masking'?

1155


What does double pointer mean in c?

1117


How can I write a function that takes a format string and a variable number of arguments?

1014


Explain how do you determine a file’s attributes?

1022


Explain bit masking in c?

1100


Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon

2253


why we wont use '&' sing in aceesing the string using scanf

2339


Explain what are preprocessor directives?

1031


What are lookup tables in c?

972