Ask Question

Write a C+ + code that will read a line of text convert it to all lower case and print it in the reverse order. Assume the maximum length of the text is 80 characters. Example input/output is shown below:

Input:

Hello sir

Output:

ris olleh

+4
Answers (1)
  1. 14 September, 09:04
    0
    C+ + program for converting it into lower case and printing in reverse order

    #include

    #include

    #include

    using namespace std;

    //driver function

    int main ()

    {

    / / Declaring two string Variables

    //strin to store Input string

    //low_string to store the string in Lower Case

    string strin, low_string;

    int i=0;

    cout<<"Input string: "<
    /*getline () method is used to store the characters from Input stream to strin string * /

    getline (cin, strin);

    //size () method returns the length of the string.

    int length=strin. size ();

    //tolower () method changes the case of a single character at a time.

    / / loop is used to convert the entire Input string to lowercase.

    while (strin[i])

    {

    char c=strin[i];

    low_string[i]=tolower (c);

    i++;

    }

    //Checking the length of characters is less than 80

    if (length<80)

    {

    cout<<"Output string: "<
    //Printing the Input string in reverse order, character by character.

    for (int i=length-1; i>=0; i--)

    {

    cout<
    }

    cout<
    }

    else

    {

    cout<<"string Length Exceeds 80 (Max character Limit) "<
    }

    return 0;

    }

    Output-

    Input string:

    Hello sir

    Output string:

    ris olleh
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a C+ + code that will read a line of text convert it to all lower case and print it in the reverse order. Assume the maximum length ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers