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
What is #define in c?
write a program to rearrange the array such way that all even elements should come first and next come odd
What is double pointer?
Which is more efficient, a switch statement or an if else chain?
how logic is used
How to define structures? ·
Explain high-order and low-order bytes.
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
What is the translation phases used in c language?
What is the sizeof () a pointer?
What is getch () for?
What are categories used for in c?
What header files do I need in order to define the standard library functions I use?
Sir i need notes for structure,functions,pointers in c language can you help me please
What is array within structure?