• Register
Welcome to Kodlogs Q&A, programming questions and answer website.

Most popular tags

java program python php javascript android c# r spring c mysql eclipse arrays python-3 exception tomcat ggplot2 spring-boot numpy html sql-server jdbc ssl sockets windows string x python-2 hibernate 7 java-8 intellij-idea ssl-certificate entity-framework macos pandas minecraft ios csv security sql json asp list net class heap-memory for-loop scikit-learn winforms illegalstateexception keytool matlab redirect code program junit pip maven ubuntu loops math facebook datetime jquery cryptography loop int import https tsql fatal-error struts java-applet spring-mvc runtime-error apache-spark pyspark garbage-collection amazon-web-services sql-server-2005 quirks-mode internet-explorer-9 internet-explorer reporting-services anova machine-learning keras indentation-error unit-testing android-studio jupyter-notebook glmnet virtualenv webclient visual-studio-2010 webpack compiler-errors numpy-ndarray curl vagrant aspnet reporting dataframe nullpointerexception javafx tensorflow jsp django jpa docker wordpress servlet indentation xcode typeerror scanner sum deployment socketexception git linux certificate css util oracle cmd node recursion search tcp syntax connection float httpwebrequest js main function number file html5 spring-data-jpa softmax elastic-beanstalk google-sheets-api google-spreadsheet-api cnf minidump xuggler acumatica gitlab elasticsearch-5 elasticsearch app-transport-security ios10 ios9 cdn cloudflare wampserver plpgsql salt-stack sysv parent-child android-edittext textview visual-studio-2012 android-workmanager unique-index unity2d unity3d electron theano maven-compiler-plugin pickle assetbundle rstudio bar-chart python-tesseract tomcat6 primefaces solr easymock jvm-crash tomcat7 apache-httpclient-4 web-services woodstox discord jersey-2 prepared-statement resultset sencha-cmd sencha-touch-2 sencha-touch powermock fips apex x509certificate ibm-bpm websphere-7 file-permissions file-io accesscontrolexception grizzly atmosphere slick2d lwjgl informetica twitter-bootstrap-3 jax-rs resteasy spring-security-kerberos spring-security kerberos long-integer mapnik pytorch git-review vpython continuation homebrew xgboost conda visual-studio android-asynctask stack-trace user-interface jaxws-maven-plugin maven-3 maven-2 browser-notsupportedexception google-maps-api-3 google-maps visual-studio-code truststore firebase-authentication aws-organizations php-7 string-formatting cplusplus visual-studio-2015 net-core net-mvc msbuild extension-methods foreign-keys windows-services react-redux reactjs inputstream facebook-graph-api entity-framework-4 reportingservices-2005 mips linear-regression deep-learning block-device melt reshape2 floating-point webpack-dev-server javascrip 0-lollipop android-5 statsmodels avx eclipseide javafx-2 php-not-recognized laravel command-line tinyurl classnotfoundexception atom-editor android-emulator android-sdk-tools ionic2 cordova foobar2k tcplistener net-2 net-4 ole-db-provider export-to-excel openrowset windows-10 vagrantfile jvm-arguments global-variables orm autopostback classformatexception eof upstart qt ipv4 graphviz pydot atom curses unityeditor pandoc tesseract xls oledb redux spotify cxf wamp nio stacked prediction headless hyperlink outlook jackson keystore applicationcontext pipeline iis jstl encryption perfect-square objective-c carthage xcode8 indexing standard-deviation sudo xampp postgresql connector apple mdf kubernetes destructor gettime arithmeticexception gmail ioexception heuristics milliseconds disk cpu npm modx-revolution goldsky modx prevnext javascript-dictionary stack-smashing device-monitor radio-button android-actionbaractivity android-activity android-fragments java-long unqualified-id ora-12154 javc c++ java nullpointerexception runtime-error drjava awt-eventqueue dsx math-pow ajquery nosuchelementexception appcompatactivity jsf jtextfield awt jpanel inputmismatchexception glassfish deque jupyter flask lvalue gradle servlets netbeans simulation ibm factorial javax apache boot opengl virtualbox jvm margins 2147483647 mongodb cloud firebase plot plugins github processor automation crash card pointers editor concatenation formatting debugging devices module testing color arraylist sequence nested date caching expected build response ip directory algorithms release collections print figure casting url expression validation integer microsoft sorting sort read types replace rest ajax exe excel dictionary message required database text variable time size dll system files table runtime static random code web map http error version 0 2 my
0 votes
How do i convert a sentence into its equivalent mobile numeric keypad sequence? Any c# code example ?
by (930 points)  

2 Answers

0 votes
Given a sentence as a string, convert it into its proportional versatile numeric keypad grouping.

Pursue the means offered underneath to change over a sentence into its identical portable numeric keypad succession.

For each character, store the succession which ought to be gotten at its separate position in an exhibit, for example for Z, store 9999. For Y, store 999. For K, store 55, etc.

For each character, subtract ASCII estimation of 'An' and acquire the situation in the cluster pointed

by that character and include the succession put away in that cluster to a string.

In the event that the character is a space, store 0

Print the general grouping.

/C++ execution to change over a

/sentence into its comparable

/portable numeric keypad succession

#include <bits/stdc++.h>

utilizing namespace std;

/Function which registers the succession

string printSequence(string arr[],

string input)


string yield = "";

/length of info string

int n = input.length();

for (int i=0; i<n; i++)


/Checking for space

on the off chance that (input[i] == ' ')

yield = yield + "0";



/Calculating record for each


int position = input[i]-'A';

yield = yield + arr[position];



/Output arrangement

return yield;


/Driver work

int principle()


/putting away the arrangement in cluster

string str[] = {"2","22","222",









string input = "KODSSFORKOODS";

cout << printSequence(str, input);

return 0;


Yield :

by (930 points)  
0 votes



Before new smart phones in olden days the phones were utilized for making calls to family and friends. These days’ smart phones are like supercomputers.

To convert a string into its equivalent mobile numeric keypad sequence, we take a string as input and store the equivalent keypad sequence of each letter in an array i.e., for A we store 2 (as in old mobile phones we have letter A on the numeric 2 and we press it once to get letter A) for B we store 22 (we press the numeric 2 twice to get the letter B)in the same way we find the numeric sequence for each letter and store it in a string.




Given a sentence in the form of a string, convert it into its equivalent mobile numeric keypad sequence.






OUTPUT: 443355555666096667775553



OUTPUT: 2233288844433388555


For obtaining a number, we need to press a number corresponding to that character for number of times equal to position of the character.


Eg: for character C we press number 2 three times and accordingly


Steps to convert a sentence into its equivalent mobile numeric keypad sequence:


For each character, store the sequence which should be obtained at its respective position in an array i.e., for Z, store 9999,for k store 55

For each character, subtract ASCII value of ‘A’ and obtain the position in the array pointed by the character and add the sequence stored in that array to a string.

If the character is a space, store 0.

Print the overall sequence.




//INPUT: String


//OUTPUT: Displays an equivalent mobile numeric keypad sequence.


    //str is used to store the sequence in an array


//outputstring is used to store the overall sequence


//inputstring is used to store the string given


//length stores the length of the inputstring


Step1: Start


//storing the sequence in an array


Step 2:Initialize str={“2”,”22”,”222,”3”,”33”,”333”,”4”,”44”,”444”,”5”,”55”,”555”,”6”,”66”,”666”,”7”,”77”,”777”,”7777”,”8”,”88”,”888”,”9”,”99,”999”“9999”}


Step3: Read inputstring


Step4: n=length of inputstring


Step5: for i=0 to n do


//check if the character is a space, add 0 to the output


                         if (inputstring[i]==’ ‘ then


                                   outputstring= outputstring+”0”






// if the character is not a a space calculate index for each character by subtracting the character by A and add the sequence stored in that index to the output




                                   outputstring= outputstring+str [index]






Step6: Display outputstring


Step 7: Stop

by (930 points)