"decimal to english" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "decimal to english" answered properly. Developers are finding an appropriate answer about decimal to english related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like decimal to english. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on decimal to english. 

decimal to english

By Mero my HeroMero my Hero on Dec 26, 2020
#include<iostream>
#include<string>

inline std::string binary_conv(int,int,std::string);

int main()
{
    long int number;
    int base {27};
    std::cout<<"\nPlease enter a non-negative integer:\t";
    std::cin>>number;
    while(number<=0)
    {
        std::cerr<<"\nWRONG!!!, Enter a number higher than zero\n";
        std::cout<<"\nPlease enter a number\t";
        std::cin>>number;
    }
    std::string binary_number;
    binary_number = binary_conv(number,base,binary_number);
    
    
    std::cout<<binary_number<<std::endl;
   
    return 0 ;
}

std::string binary_conv(int number, int base,std::string binary)
{   
    std::string zero_one = " abcdefghijklmnopqrstuvwxyz";
    if(number==0)
        return binary;
    binary = zero_one[number%base]+binary;
    number/=base;
    return binary_conv(number,base,binary);
}

Add Comment

0

english to decimal

By Mero my HeroMero my Hero on Jan 02, 2021
#include<iostream>
#include<cmath> 
#include<limits>
#include<string>
void print_value(const size_t value);
// bool IllegalCharacters(int,const std::string, int);
bool isalpha_isspace(const std::string&);


int main()
{
    std::string eng2dec;
    std::cout<<"\nPlease enter a string of small letters and spaces:\t";
    getline(std::cin,eng2dec);

    // checking if string is an alphabet or spaces 
    bool answer = isalpha_isspace(eng2dec);
    if(answer == false)
    {
        std::cout<<"\nThe input string does not represent a number in base 27"<<std::endl;
        exit(1);
    }
    // looping throught the string and converting the value of chars to decimal with base 27
    size_t value {0};
    int decimal {0};
    for(size_t i {0}; i<eng2dec.length(); ++i)
    {   
        if(eng2dec[i]==' ')
        {
            decimal=0;
        }else{
            int power = (eng2dec.length()-1-i);
            decimal = eng2dec[i]%96;   
            value+= decimal*pow(27,power); 
        }
        if(value > pow(2,32)){
            std::cout<<"\nThe input string represents a number that is greater than 2ˆ32" <<std::endl;exit(1);
        } 
    }
    print_value(value);  
    return 0 ;
}

// check if string is not alphabet or space 
bool isalpha_isspace(const std::string& str )
{   
    bool answer ;
    for(char c: str){
        if(isalpha(c) || isspace(c)) 
        {
           answer = true;
        }else
        {
           answer= false;
        }
    }
    return answer ;
}

// print value 
void print_value(const size_t value){
	std::cout<<value<<std::endl;         
}

Add Comment

0

english to decimal

By Mero my HeroMero my Hero on Dec 26, 2020
#include<iostream>
#include<string>
#include<cmath>

int main()
{   

  
    std::cout<<"Please enter a string of small letters and spaces:\t";
    std::string str ;
    getline(std::cin, str) ;

    
    long int  result {0};
    long int  value {0};
    for(int i=0 ; i < str.length(); ++i)
    {

        switch(str[i]){
        
            case ' ':
                value = 0;
                break;
            case 'A':
            case 'a':
                value = 1;
                break;
            case 'B':
            case 'b':
                value = 2;
                break;
            case 'C':
            case 'c':
                value = 3;
                break;
            case 'D':
            case 'd':
                value = 4;
                break;
            case 'E':
            case 'e':
                value = 5;
                break;
            case 'F':
            case 'f':
                value = 6;
                break;
            case 'G':
            case 'g':
                value = 7;
                break;
            case 'H':
            case 'h':
                value = 8;
                break;
            case 'I':
            case 'i':
                value = 9;
                break;
            case 'J':
            case 'j':
                value = 10;
                break;
            case 'K':
            case 'k':
                value = 11;
                break;
            case 'L':
            case 'l':
                value = 12;
                break;
            case 'M':
            case 'm':
                value = 13;
                break;
            case 'N':
            case 'n':
                value = 14;
                break;
            case 'O':
            case 'o':
                value = 15;
            case 'P':
            case 'p':
                value = 16;
                break;
            case 'Q':
            case 'q':
                value = 17;
                break;
            case 'R':
            case 'r':
                value = 18;
                break;
            case 'S':
            case 's':
                value = 19;
                break;
            case 'T':
            case 't':
                value = 20;
                break;
            case 'U':
            case 'u':
                value = 21;
                break;
            case 'V':
            case 'v':
                value = 22;
                break;
            case 'W':
            case 'w':
                value = 23;
                break;
            case 'X':
            case 'x':
                value = 24;
                break;
            case 'Y':
            case 'y':
                value = 25;
                break;
            case 'Z':
            case 'z':
                value = 26;
                break;
            default:
                std::cout<<" The input string does not represent a number in base 27 "<<std::endl;
        } 
        int power = (str.length()-1-i);
        result += value*(pow(27,power));
    }
    if(str.length()>= 32)
    {           
        std::cout<<"\nThe input string represents a number that is greater than 2ˆ32"<<std::endl;
        
    }else{
        std::cout<<"\n"<<result<<std::endl;
    }
    

    return 0 ;
}

Add Comment

0

english to decimal

By Mero my HeroMero my Hero on Dec 26, 2020
#include<iostream>
#include<string>
#include<limits>

inline std::string binary_conv(int,int,std::string);

int main()
{
    long int number;
    int base {27};
    std::cout<<"\nPlease enter a non-negative integer:\t";
    std::cin>>number;


    while(1)
    {
        if(std::cin.fail())
        {
        std::cin.clear();
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
        std::cout<<"\nYou have entered wrong input!"<<std::endl;
        std::cout<<"\nPlease enter a non-negative integer:\t";
        std::cin>>number;
    }
        if(!std::cin.fail())
        break;
    }
    
    std::string binary_number;
    binary_number = binary_conv(number,base,binary_number);
    
    
    std::cout<<binary_number<<std::endl;
   
    return 0 ;
}

std::string binary_conv(int number, int base,std::string binary)
{   
    std::string zero_one = " abcdefghijklmnopqrstuvwxyz";
    if(number==0)
        return binary;
    binary = zero_one[number%base]+binary;
    number/=base;
    return binary_conv(number,base,binary);
}


Add Comment

0

All those coders who are working on the C++ based application and are stuck on decimal to english can get a collection of related answers to their query. Programmers need to enter their query on decimal to english related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about decimal to english for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of decimal to english while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "decimal to english". Visit this developer's friendly online web community, CodeProZone, and get your queries like decimal to english resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "decimal to english"

View All C++ queries

C++ queries related to "decimal to english"

Browse Other Code Languages

CodeProZone