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...

You have an array of n integers, randomly ordered with value 1
to n-1.The array is such that there is only one and one value
occurred twice. How will you find this number?

Answer Posted / balaji ganesh

#include<stdio.h>
void main()
{
int a[100],n,i,j;
clrscr();
scanf("%d",&n,printf("enter size of array:"));
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(a[i]==a[j])
{
printf("second occurence value: %d",a[i]);
break;
}

getch();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are local static variables?

1079


Explain logical errors? Compare with syntax errors.

1008


What is the correct code to have following output in c using nested for loop?

1024


I heard that you have to include stdio.h before calling printf. Why?

1006


What are the string functions? List some string functions available in c.

947


Can one function call another?

1046


What is a wrapper function in c?

1070


What is difference between main and void main?

1110


In a header file whether functions are declared or defined?

1076


When should a type cast not be used?

1003


Is it acceptable to declare/define a variable in a c header?

1059


Is null equal to 0 in sql?

1088


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

2243


What is the meaning of && in c?

961


When is a void pointer used?

1189