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?



You have an array of n integers, randomly ordered with value 1 to n-1.The array is such that there..

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

More C Interview Questions

control 50 devices which has 2 states on and off.using bitwise operator.plz answer it its urgent

1 Answers  


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

0 Answers  


What is boolean in c?

0 Answers  


Which is not valid in C? 1) class aClass{public:int x;} 2) /* A comment */ 3) char x=12;

7 Answers  


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

0 Answers  


every function has return the value?

1 Answers  


What is a structure in c language. how to initialise a structure in c?

0 Answers  


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

1 Answers   TCS,


Find MAXIMUM of three distinct integers using a single C statement

0 Answers  


what is the purpose of the following code, and is there any problem with the code? void fn(long* p1, long* p2) { register int x = *p1; register int y = *p2; x ^= y; y ^= x; x ^= y; *p1 = x; *p2 = y; }

1 Answers   Google,


What does the file stdio.h contain?

0 Answers  


Why is void main used?

0 Answers  


Categories