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
Can two or more operators such as and be combined in a single line of program code?
Why is a semicolon (;) put at the end of every program statement?
What is the ANSI C Standard?
Explain what are the advantages and disadvantages of a heap?
What 'lex' does?
What is meant by preprocessor in c?
Explain what is meant by 'bit masking'?
What does double pointer mean in c?
How can I write a function that takes a format string and a variable number of arguments?
Explain how do you determine a file’s attributes?
Explain bit masking in c?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
why we wont use '&' sing in aceesing the string using scanf
Explain what are preprocessor directives?
What are lookup tables in c?