Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

1.find most occurrences of a character.

for exm: input:aaabbbbdddddyyy
output: d 5 times
how can i get that?


Answer Posted / sagar wagh

Dcl-S inputString Char(30) Inz('aaabbbbdddddyyy');
Dcl-S charCount Int(10);
Dcl-S maxCount Int(10) Inz(0);
Dcl-S maxChar Char(1);
Dcl-S i Int(10);
Dcl-S j Int(10);

For i = 1 to %Len(%TrimR(inputString));
charCount = 0;
For j = 1 to %Len(%TrimR(inputString));
If %Subst(inputString: j: 1) = %Subst(inputString: i: 1);
charCount += 1;
EndIf;
EndFor;
If charCount > maxCount;
maxCount = charCount;
maxChar = %Subst(inputString: i: 1);
EndIf;
EndFor;

Dsply ('Character ' + maxChar + ' occurs ' + %Char(maxCount) + ' times');
*InLR = *On;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the use of sflnxtchg?

1210


what is data area and how it is used in rpg program ?

1266


do you use message subfiles? What are the necessary keywords required coding a message subfile?

1081


how do I declare a minor?

1110


What is ment by record level identifier?

1087


during execution, an rpg/400 program automatically follows a sequence of operations for each record that is processed. The built-in program cycle includes the following logical steps.

1149


How to select highest score of each subject or how to select highest income of every month?

1709


Hi Viewers can any body explain me how to update and ahange the already existed data in physical file using subfile ? please explain me with the code if possible?

5063


what is an online rpg?

1197


how can I tell when to replace the array?

1155


what is the rpg system?

1220


how do you use commitment control in rpg?

1225


What is the difference between copybooks and subprocedures in as400?

1308


Assume 2 users are using the same file and first user updates some record in the file. Will the 2nd user will be able to see the updated record or not?

889


What is difference between bind by copy and bind by reference?

2397