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 |
What are the different types of data structures in c?
print out of string in this format; 1. "rajesh" 2. \n 3. %d
what is pointer?
what information does the header files contain?
6 Answers BSNL, Cisco, GDA Technologies,
What is wild pointer in c with example?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
what is the mean of c languages.
Write a function to find the area of a triangle whose length of three sides is given
What is a void * in c?
When should a type cast not be used?
main() { int x=2, y=4 if ((x==2||y==4) x++ y++ if (y==4+1) { x=x+y; } y++; printf("The values of x and y are %d and %d."x,y); } What is the output?
Hai why 'c' is the middle language