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 ?    33 Yes 14 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 ?    4 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 / 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 / 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 1 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 2 No

Post New Answer

More General Aptitude Interview Questions

Which number does not belong to this series 1,1,2,3,4,5,8,13,21?

0 Answers   Google,


Can any one send me question paper of obc po exam held on 21v december 2008 on my email Pinkys.y18@gmail.com

0 Answers  


Integral B(Transpose)*sigma(here sigma means stress)*dV REPRESENTS?

0 Answers  


How many times the President of India can seek re-election to his post? a) Once b) 2 times c) 3 times d) Any number of times

7 Answers   GE Healthcare, RRB, Smart Bridge, Sodexo,


If A=Z, B=Y, C=X, .......... Z=A, Then POCKET = ?

0 Answers   Baan Infotech,






albert and fernandes they have two leg swimming race. both start from opposite and of the pool. On the first leg, the boys pass each other at 18 mt from the deep end of the pool. during the II leg they pass at 10 mt from the shallow end of the pool. Both go at const speed. but one of them is faster. each boy rests for 4 sec to see at the end of the i leg. what is the length of the pool.

0 Answers   InfoTest,


If D is adjacent to F then who is adjacent to C?

0 Answers   Wipro,


if a boat is moving in upstream with v1 km/hr and in the down stream it is moving with v2 km/hr then what is the speed of the stream.

6 Answers   IIT Delhi, MBT,


Eon asked 60 students whether they listen to two popular radio stations, WROK and WRAP. He found that 23 listen to WROK, 18 listen to WRAP, and 8 listen to both. How many students in Robert's survey listen to a) WROK but not WRAP b) WRAP but not WROK c) neither WROK nor WRAP

0 Answers   CSC,


Which of the following letters does not belong in the sequence? A, E, I, F, U

7 Answers   TATA, TCS,


f(X)= f(X-1)+f(X-2) FOR X>1 THEN X= ?

0 Answers   CTS,


12 Blacksox and 12 Whitesox mixed in a box,a pair of sox is picked at a time,in which pick how many pick ,to get the right pair(black&black or white&white)?

0 Answers   Accenture,


Categories