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

Write a code to generate a series where the next element is the sum of last k terms.

0 Answers   Aspiring Minds,


What does c mean in standard form?

0 Answers  


How to add two numbers without using arithmetic operators?

18 Answers   College School Exams Tests, e track, Infosys, Pan Parag, Sapient, TCS,


the data type used for unlimited value in c and how to do this program

1 Answers  


Can we assign integer value to char in c?

0 Answers  






What is malloc calloc and realloc in c?

0 Answers  


Define and explain about ! Operator?

0 Answers  


How to set a variable in the environment list?

1 Answers  


Explain the red-black trees?

0 Answers  


What is a sequential access file?

0 Answers  


Determine if a number is a power of 2 at O(1).

2 Answers  


what is the output of the below code? main( ) { printf ( "\nOnly stupids use C?" ) ; display( ) ; } display( ) { printf ( "\nFools too use C!" ) ; main( ) ; }

3 Answers  


Categories