You have an array of n integers, randomly ordered with value 1
to n-1.The array is such that there is only one and one value
occurred twice. How will you find this number?
Answer Posted / balaji ganesh
#include<stdio.h>
void main()
{
int a[100],n,i,j;
clrscr();
scanf("%d",&n,printf("enter size of array:"));
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(a[i]==a[j])
{
printf("second occurence value: %d",a[i]);
break;
}
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why does everyone say not to use gets?
Explain the difference between call by value and call by reference in c language?
What is the -> in c?
What are the types of arrays in c?
What is identifiers in c with examples?
Can you please compare array with pointer?
What is an lvalue?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
how to count no of words,characters,lines in a paragraph.
Is there a way to jump out of a function or functions?
How do you define a function?
Can we change the value of constant variable in c?
How can a string be converted to a number?
write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34