to remove the repeated numbers from the given .
i.e..,
if the input is 12233
output should of
123

Answers were Sorted based on User's Feedback



to remove the repeated numbers from the given . i.e.., if the input is 12233 output should of 1..

Answer / sujai cn

#include <iostream>
#include <math.h>
#include<conio.h>
using namespace std;

void main()
{
int num = 0;
int ReverseNumber(int num);
int RemoveDuplicateDigits(int num);
int ReverseOfInput = 0;
cout<<"Please enter the number\n";
cin >> num;
ReverseOfInput = ReverseNumber(num);
cout<<"The number after removing duplicate digits is "
<< ReverseNumber(RemoveDuplicateDigits(ReverseOfInput)) ;
getch();
}

int ReverseNumber(int num)
{
int revnum = num;
int nodigits = 0;
int rem = 0;
while(revnum > 0)
{
nodigits ++;
revnum = revnum / 10;
}

revnum = 0;
nodigits --;
while(num > 0)
{
rem = num % 10 ;
revnum = revnum + rem * (int) (pow (10 ,nodigits));
nodigits --;
num = num / 10;
}

return revnum;
}

int RemoveDuplicateDigits(int num)
{

int resnum = 0;
bool digis[10] = {false , false ,false ,
false ,false , false ,false , false , false , false};
int power = 0;
int rem = 0;

while (num > 0)
{
rem = num % 10 ;
if(digis[rem] == false)
{
resnum = (int)(resnum + rem * pow(10 , power));
power++;
digis[rem] = true;
}
num = num / 10 ;
}

return resnum;
}

Is This Answer Correct ?    1 Yes 0 No

to remove the repeated numbers from the given . i.e.., if the input is 12233 output should of 1..

Answer / qapoo

int main()
{
int a[5]={1,2,2,3,3};
for(int i=0;i<5;i++)
{
if(a[i]<a[i+1])
cout<<a[i];
}
return 0;
}

Is This Answer Correct ?    4 Yes 8 No

Post New Answer

More OOPS Interview Questions

what isthe difference between c structure and c++ class

5 Answers  


what is object oriented programming and procedure oriented programming?

3 Answers  


create a c++ program that will accepts 9 inputs using 3 by 3 array.

1 Answers  


Where is pseudocode used?

0 Answers  


explain sub-type and sub class? atleast u have differ it into 4 points?

0 Answers   Infosys,






Is react oop?

0 Answers  


You attempt to query the data base with this command: SELECT name, salary FROM employee WHERE salary=(SELECT salary FROM employee WHERE last name='Wagner' OR dept no=233) Choose most appropriate option from the following: 1)Sub-queries are not allowed in the where clause. 2)a multiple row sub-query used with a single row comparison operator. 3)a single row query is used with a multiple row comparison operator.

10 Answers   Zycus Infotech,


Why is encapsulation used?

0 Answers  


is java purely oop Language?

49 Answers   HCL, Infosys, TCS,


swapping program does not use third variable

5 Answers   TCS,


Which type does string inherit from?

0 Answers  


What are the advantanges of modularity

2 Answers  


Categories