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 is #define in c?

812


write a program to rearrange the array such way that all even elements should come first and next come odd

2016


What is double pointer?

757


Which is more efficient, a switch statement or an if else chain?

778


how logic is used

1706


‎How to define structures? · ‎

834


Explain high-order and low-order bytes.

865


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

1372


What is the translation phases used in c language?

826


What is the sizeof () a pointer?

735


What is getch () for?

878


What are categories used for in c?

801


What header files do I need in order to define the standard library functions I use?

743


Sir i need notes for structure,functions,pointers in c language can you help me please

2168


What is array within structure?

824