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 / 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 |
Write a code to generate a series where the next element is the sum of last k terms.
What does c mean in standard form?
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
Can we assign integer value to char in c?
What is malloc calloc and realloc in c?
Define and explain about ! Operator?
How to set a variable in the environment list?
Explain the red-black trees?
What is a sequential access file?
Determine if a number is a power of 2 at O(1).
what is the output of the below code? main( ) { printf ( "\nOnly stupids use C?" ) ; display( ) ; } display( ) { printf ( "\nFools too use C!" ) ; main( ) ; }