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

Mirror image of ear.

2 Answers   3D PLM,


X's father's wife's father's granddaughter uncle will be related to X as?

1 Answers   Wipro,


In a class total 34 students, 16 are have a brother, 15 are have sisters, 9 students don't have either brothers or sisters.Find the number of students having both brother and sisters.

0 Answers   Hexaware,


In certain code 'OPERATION' is written as 'POREAITNO'How is DREAMLAND written in that code.

4 Answers   Infosys,


Find the next number in the series 1, 3 ,7 ,13 ,21 ,31?

0 Answers   Wipro,






What is alternate function for clrscr().

5 Answers   Cap Gemini,


man walks east & from turns to right & from to left &then 45degrees to right.in which direction he went

9 Answers   Cognizant, Patni,


How many 3-digit numbers with atleast one 5 in their digits?

0 Answers   Huawei,


Two trains 100 meters and 120 meters long are running in the same directions with speed of 72 km/hr and 54 km./hr. in how much time will the first train cross the second?

0 Answers   Axis Bank,


A train blows a siren one hour after starting from the station. After that it travels at 3/5th of its speed it reaches the next station 2 hours behind schedule. If it had a problem 50 miles farther from the previous case,it would have reached 40 minutes sooner. Find the distance between the two stations .

0 Answers   Infosys,


Find the missing number in the series: 2, 5, __ , 19 , 37, 75

0 Answers   TCS,


i am preparing for SBI clerical exam and also for oriental bank of commerce .. i need previous exam question paper for last 10 years .. pls can you send it to me by email id .. pls help me

0 Answers   State Bank Of India SBI,


Categories