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
HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????
What are the complete rules for header file searching?
What is a c token and types of c tokens?
given post order,in order construct the corresponding binary tree
Here is a good puzzle: how do you write a program which produces its own source code as output?
What is array in C
Why #include is used in c language?
What does != Mean in c?
How can I pad a string to a known length?
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
Can we assign string to char pointer?
Why do we use int main?
What is the value of c?
where are auto variables stored? What are the characteristics of an auto variable?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list