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 / 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 |
hOW Can I add character in to pointer array of characters char *a="indian"; ie I want to add google after indian in the char *a
Why clrscr is used in c?
i want to know aptitude questions,technical questions
What is a program?
Why is c so important?
Define the scope of static variables.
What are the general description for loop statement and available loop types in c?
How can I trap or ignore keyboard interrupts like control-c?
Write a program to reverse a linked list in c.
Code for calculating square root without using library function, of math.h
What is the difference between int main and void main?
Concat two string with most overlapped substring has to removeĀ "abcd"+ "cdef" = "abcdef