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 / pushpa
int num[3];
int i,j,p=0,count_1=0,count=0,n;
n= 3;
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(num[i] == num[j])
count_1=0;
else
count++;
}
if(count == n-1)
{
printf("The number which occurs once is %d\n",num[i]);
}
count = 0;
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Is void a keyword in c?
What is c token?
Do you know the use of fflush() function?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
What is #define in c?
write a program to find out prime number using sieve case?
What is the difference between int main and void main?
What is meant by operator precedence?
Do pointers take up memory?
Write a simple code fragment that will check if a number is positive or negative.
What is meant by realloc()?
What are formal parameters?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
Why can't I perform arithmetic on a void* pointer?
What is else if ladder?