Question

Write a program that takes in a line of text as input, and outputs that line of text in reverse. You may assume that each lin

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>
#include <string.h>

int main() {
    char s[50];
    int i;
    fgets(s, 50, stdin);
    while (strcmp(s, "Quit\n") != 0 && strcmp(s, "quit\n") != 0 && strcmp(s, "q\n") != 0) {
        i = strlen(s) - 2;
        while (i >= 0) {
            printf("%c", s[i]);
            i--;
        }
        printf("\n");
        fgets(s, 50, stdin);
    }
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Write a program that takes in a line of text as input, and outputs that line...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that takes in a line of text as input, and outputs that line of text in reverse.

    Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text.Ex: If the input is:Hello there Hey quitthen the output is:ereht olleH yeHThere is a mistake in my code I can not find. my output is : ereht olleH ereht olleHyeHHow can I fix this?I saw some people use void or the function reverse but we didnt...

  • Write a program that takes in a line of text as input, and outputs that line of text in reverse.

     4.24 LAB: Print string in reverse Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or 'q" for the line of text. Ex: If the input is: Hello there Hey quit the output is: ereht ollel yeH

  • C++ Print string in reverse

    Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text.Ex: If the input is:Hello there Hey quitthen the output is:ereht olleH yeH

  • Write a Perl program that prompts a use to input a line of text. If the line of text mentions bot...

    Write a Perl program that prompts a use to input a line of text. If the line of text mentions both John and Smith, the program outputs “FOUND.” Otherwise, it outputs “NOT FOUND.” Write a Perl program that prompts a use to input a line of text. If the line of text has a word that is capitalized but not ALL capitalized, the program outputs “FOUND.” Otherwise, it outputs “NOT FOUND”. For example, if the user enters “Fred,” the program...

  • Write a Perl program that prompts a use to input a line of text. If the...

    Write a Perl program that prompts a use to input a line of text. If the line of text has a word that is capitalized but not ALL capitalized, the program outputs “FOUND.” Otherwise, it outputs “NOT FOUND”. For example, if the user enters “Fred,” the program outputs “FOUND.” But if the user enters “fred” or “FRED,” the program outputs “NOT FOUND.”

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • Write a C program that prompts the user for an input string with all lowercase letters....

    Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.

  • Objectives: Use strings and string library functions. Write a program that asks the user to enter...

    Objectives: Use strings and string library functions. Write a program that asks the user to enter a string and output the string in all uppercase letters. The program should then display the number of white space characters in the string. You program should run continuously until the user enters an empty string. The program must use the following two functions: A function called count_spaces that counts the number of white spaces inside a string. int count_space(char str[]); which tell you...

  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

  • Using Java write a program that takes a string input from the user and then outputs...

    Using Java write a program that takes a string input from the user and then outputs the first character, then the first two, then the first three, etc until it prints the entire word.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT