Input an array and then print the repeating characters??
Example:
Input:1,3,23,11,44,3,23,2,3.
Output:3,23
plz help me.... i want a code of it. In C language.

Answers were Sorted based on User's Feedback



Input an array and then print the repeating characters?? Example: Input:1,3,23,11,44,3,23,2,3. Ou..

Answer / amit rawat

#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int ar[8]={2,3,4,5,2,9,8,7};
for(int i=0;i<8;i++)
{for(int j=i+1;j<8;j++)
{if(ar[i]==ar[j])
{cout<<"\n Repeated no is";cout<<ar[i];
}
}
}
getch();
}

Is This Answer Correct ?    27 Yes 11 No

Input an array and then print the repeating characters?? Example: Input:1,3,23,11,44,3,23,2,3. Ou..

Answer / ankit dhanna

#include<iostream.h>
#include<conio.h>
void main()
{
int a[8],i,j,k,temp[8];
k=0;
cout<<"enter 8 elements "<<endl;
for(i=0;i<8;i++)
{
cin>>a[i];
}

for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
if((a[i]==a[j])&&(i!=j))
{

temp[k]=a[i];
k++;
}

}
}

for(i=0;i<k/2;i++)
{
cout<<"repeated element "<<temp[i];
}

getch();
}

Is This Answer Correct ?    16 Yes 15 No

Input an array and then print the repeating characters?? Example: Input:1,3,23,11,44,3,23,2,3. Ou..

Answer / amit kumar mehta

#include<iostream>
using namespace std;

int main() {
int a[] = {1,3,23,11,44,3,23,2,3};
// for ( i = 0; i < 10; ++i) {
// cin >> a[i];
// }
for ( int i = 0; i < 9 ; i++) {
int count = 0;
for (int j = i+1; j < 9; j++) {
if (a[i] == a[j]) {
count++;
}
}
if (count > 0) {
int temp[10];
int rep = 0;
for (int m = 0; m < 10; ++m) {
if (a[i] == temp[m]) {
rep++;
}
}
if (rep <= 0) {
cout << a[i] << " ";
temp [i] = a[i];
}
}
}
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

Input an array and then print the repeating characters?? Example: Input:1,3,23,11,44,3,23,2,3. Ou..

Answer / saurabh singh

n = [int(x) for x in input().split()]
for i in range(len(n)):
for j in range(i+1, len(n)):
if n[i] == n[j]:
print(n[i])

#saurabhsingh

Is This Answer Correct ?    0 Yes 0 No

Input an array and then print the repeating characters?? Example: Input:1,3,23,11,44,3,23,2,3. Ou..

Answer / rahulkashyaprajput

package repeatingno;
import java .io.*;
public class Reap
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int no,max=0,n,count=0;
System.out.println("enter no of elements");
no=Integer.parseInt(br.readLine());
int ar[] = new int[no];
System.out.println("enter elements");
for(int i=0;i<no;i++)
ar[i]=Integer.parseInt(br.readLine());
for(int i=0;i<no;i++)
{
if(ar[i]>max)
{
max=ar[i];
}

}
System.out.println("repeated elements are");
for(int i=0;i<=max;i++)
{ for(int j=0;j<no;j++)
{
if(i==ar[j])
count++;
}

if(count>1)
System.out.print(i+" ");
count=0;
}

}
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer



More General Aptitude Interview Questions

Two trains move in the same direction at 50 kmph and 32 kmph respectively. A man in the slower train observes the 15 seconds elapse before the faster train completely passes by him.

0 Answers   3i Infotech,


What are software testing metrics

1 Answers   Persistent,


An apple seller is having some apples. He is selling half of the apple what he has plus half the apple to the first customer. In the same way he sells the remaining apple to 7 customers. After selling to 7 customers, he has no apples with him.

0 Answers   Accenture,


what is the cost of 475.5rs share with 4%discount and 1/4%brokerage

3 Answers  


There are first 20 numbers.what is the probability of selecting a even no such that the no is less than 7?

6 Answers  






what is the magic word in english

4 Answers   Cegedim,


Please send the SBI model question paper.

3 Answers   State Bank Of India SBI,


In 80 coins one coin is counterfeit what is minimum number of weighings to find out counterfeit coin

0 Answers   TCS,


How many two digit numbers satisfy the property: the last digit of the square of the two digit number is 8:

0 Answers   Verifone,


if 2^51 is 8 then 2^48 is ?

3 Answers  


Please provide some links or materials for IOB PROBATIONARY OFFICERS post exam

0 Answers  


Six drinking glasses stand in a row, with the first three full of juice and the next three empty. By moving only one glass can you arrange them so empty and full glasses alternate?

6 Answers   Capita, PT Metalogix Infolink Persada, TCS,






Categories