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

Plz send me GK question , current affairs..........

0 Answers  


what is the angle between two hands of a clock when time is 8-30

0 Answers   Cognizant,


If it costs x dollors for making certain item if quantity is 1000 and if quantity increase then the item is made using y dollars. If z number of items are made which are greater than 1000 then what is the total cost.

6 Answers   College School Exams Tests, Samsung,


An article sold at a profit of 20% if both the cost price and selling price would be Rs.20/- the profit would be 10% more. What is the cost price of that article?

0 Answers   3i Infotech, Amazon, Canara Bank,


Why RSD of area limit is 15?

0 Answers   Altisource, UPL,


X is 3 years younger to Y. X's father is a businessman who invested 10000/- at 8% rate of interest n obtained his amount after 10 years. Y's father is a job holder who invested around 20000 at 2% rate n obtained his amount after 20 years.Now Compunded both of dem get around ABC rs/- (dnt remenbr). After 5 years the ratio of ages of X n Y is 1:2. Now X's father is 20 years older to Y n Y' father is 30 years more than X. After 20 years again. X's mother asks X's father to purchase a LCD TV which costs around 45000/-. what is the age of X n Y together

2 Answers   TCS,


The average of 4 consecutive even numbers is 27. What is the largest number?

0 Answers   Accenture,


Alphametics are puzzles where each letter stands for a different digit. Here are two alphametics. No word can begin with a zero. We’ve started you out with some of the letters. BASE + BALL -------------- GAMES what these alphabets represent

0 Answers   ProKarma,


hi, i have filled up the EPFO exam form i m bsc chemsitry graduate so can any1 guide me wat all questions will be asked in office work aptitue??? so thati can do my preparation in exam???

6 Answers   Vodafone,


One train leaves Los Angeles at 15mph heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they collide, how far will the bird have traveled?

21 Answers   Microsoft,


I bought a car with a peculiar 5 digit numbered license plate which on reversing could still be read. On reversing value is increased by 78633. What's the original number if all digits were different?

1 Answers   Infosys,


There is square of side 6 cm .A circle is inscribed inside the square Find the ratio of area of circle to the squqre .

0 Answers   CMC,


Categories