Given an array of numbers, except for one number all the
others occur twice. Give an algorithm to find that number
which occurs only once in the array.
Answer Posted / don151
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,n,b[10],m,k,temp;
clrscr();
printf("eneett the v vallrue of n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("before sorting array");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[j]>=a[i])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
printf("after sorting");
for(i=0;i<n;i++)
{
printf("\n%d",a[i]);
}
for(i=0;i<n;i+=2)
{
if(a[i]!=a[i+1])
{
printf("resutl for %d,%d\n",i,a[i]);
i++;
}
}
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is fflush() function?
Why is sprintf unsafe?
what will be maximum number of comparisons when number of elements are given?
What standard functions are available to manipulate strings?
Explain is it valid to address one element beyond the end of an array?
count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array
How can I find out if there are characters available for reading?
What is 2 d array in c?
Write a program to print “hello world” without using semicolon?
What do you mean by scope of a variable in c?
How do you construct an increment statement or decrement statement in C?
What type of function is main ()?
Who invented b language?
What is the difference between NULL and NUL?
can anyone suggest some site name..where i can get some good data structure puzzles???