Question

C Programming // use stdio.h, stdlib.h, string.h and math.h only. Write a program that prompts the...

C Programming // use stdio.h, stdlib.h, string.h and math.h only.

Write a program that prompts the user to enter a word that has 3 letters. Store this as a character array (i.e. strings in C). Create a new character array that stores the reverse of the word and display on the screen.

Sample output is as follows:

Enter a word with 3 letters> bee
Word entered: bee
Reverse word: eeb

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

int main ()
{
   char input[4], res[4];
   int i, k=0;
   printf("Enter a word with 3 letters> ");
   scanf("%s",&input);
   
   for(i = 2;i>=0;i--){
      res[k++]=input[i];
   }
   res[k]='\0';
   
   printf("Word entered: %s\n",input);
   printf("Reverse word: %s\n",res);
   return 0;
}

nter a word with 3 letters> bee Word entered bee Rever se word eelb Process exited after 1.082 seconds with return value0 Press any key to continue . -

Please upvote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
C Programming // use stdio.h, stdlib.h, string.h and math.h only. Write a program that prompts the...
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
  • C Programming // only using #include<stdio.h> #include<stdlib.h> A rational number is any number that can be...

    C Programming // only using #include<stdio.h> #include<stdlib.h> A rational number is any number that can be expressed as a fraction of two integers. Write a program that reads a rational number from the user and display it as a mixed numeral. Example run 1: Enter the numerator and denominator separated by a space> 22 7 22/7 = 3 1/7 Example run 2: Enter the numerator and denominator separated by a space> 3 4 3/4 = 0 3/4

  • 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...

  • Use C++ language, keep it simple Exercise #2: Strings' operations Write a C++ program that prompts...

    Use C++ language, keep it simple Exercise #2: Strings' operations Write a C++ program that prompts the user to enter a sentence, the program then does the following: 1. Prints the total characters in the sentence. 2. Prints the word count of the sentence, assuming only one space between each tow words. 3. Prints total vowel (a, e, i, o, u) in the sentence. 4. Prints the vowel frequency as shown in the sample below. 5. Prints the sentence in...

  • #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #pragma warning(disable : 4996) // to avoid scanf...

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #pragma warning(disable : 4996) // to avoid scanf error, Visual Studio only #define MAX_DIM 3 #define STUDENTS 5            // total number of students int scores[STUDENTS]; int *pScores = NULL; C language Implement the function that creates and displays the user name of the user. Ask the user for their first and last name. The username is the first letter of first name, followed by the last name. For instance, if the user's...

  • Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...

    Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program 3 - Hangman Game Assignment purpose: User defined functions, character arrays, c style string member functions Write an interactive program that will allow a user to play the game of Hangman. You will need to: e You will use four character arrays: o one for the word to be guessed (solution) o one for the word in progress (starword) o one for all of...

  • Write a C++ program that prompts the user with the following menu options: [E]rase–ArrayContent [C]ount–Words [R]ev–Words...

    Write a C++ program that prompts the user with the following menu options: [E]rase–ArrayContent [C]ount–Words [R]ev–Words [Q]uit 1. For Erase–ArrayContent option, write complete code for the C++ function Erase described below. The prototype for Erase is as follows: void Erase( int a[ ], int * N, int * Search-Element ) The function Erase should remove all occurrences of Search-Element from the array    a[ ]. Note that array a[ ] is loaded with integer numbers entered by the user through the...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • 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 program that prompts the user for a String value and a character value. The...

    Write a program that prompts the user for a String value and a character value. The program should then find the last occurrence of the provided character in the provided String and display the corresponding index. If the character is not found in the String, display -1. For additional challenge, create a multi-class solution. The business class should consist of two instance varaibles to store the user provided values and one method to accomplish the given task. The tester class...

  • In Java Programming: Create a flow chart for a program that prompts for an integer N...

    In Java Programming: Create a flow chart for a program that prompts for an integer N (number of students) and M (number of test scores for each students), and allows the user to N*M real numbers. The program then calculates the average for each student and class average. (1) Prompt the user to input N students and M test scores, then display the inputs. Enter number of students: You entered: 2 Enter number of test scores: You entered: 3 Enter...

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