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
Are the variables argc and argv are always local to main?
What is the argument of a function in c?
Explain what standard functions are available to manipulate strings?
Explain about the functions strcat() and strcmp()?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What is structure pointer in c?
Explain how do you determine the length of a string value that was stored in a variable?
What is difference between structure and union in c programming?
find the sum of two matrices and WAP for it.
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
Is c is a high level language?
What is the use of volatile?
what will be the output for the following main() { printf("hi" "hello"); }
What is the difference between ++a and a++?