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
Can you explain the four storage classes in C?
How do I get a null pointer in my programs?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
What is a loop?
Do you know the difference between malloc() and calloc() function?
Define recursion in c.
define string ?
Explain the process of converting a Tree into a Binary Tree.
What is character constants?
Write a program to print factorial of given number using recursion?
Explain how can I remove the trailing spaces from a string?
What is auto keyword in c?
What is the use of header files?
Can we use any name in place of argv and argc as command line arguments?