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
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
What is data type long in c?
Why void is used in c?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
Write a program to print fibonacci series without using recursion?
How is = symbol different from == symbol in c programming?
What is a global variable in c?
What is the right type to use for boolean values in c? Is there a standard type?
Differentiate between full, complete & perfect binary trees.
What do you mean by invalid pointer arithmetic?
Explain how do you override a defined macro?
What does *p++ do?
What is advantage of pointer in c?
What are the application of void data type in c?