Computer Science, asked by mintyautumn6, 29 days ago

Write a program in C++ that allows the user to input any string and then print out the following:
1. The number of words in string.
2. The string in reverse order.​

Answers

Answered by yuvikanirwan
1

Answer:

Print words of a string in reverse order

Let there be a string say “I AM A GEEK”. So, the output should be “GEEK A AM I” . This can done in many ways. One of the solutions is given in Reverse words in a string .

Examples:

Input : I AM A GEEK

Output : GEEK A AM I

Input : GfG IS THE BEST

Output : BEST THE IS GfG

This can be done in more simpler way by using the property of the “%s format specifier” .

Property: %s will get all the values until it gets NULL i.e. ‘\0’.

Example: char String[] = “I AM A GEEK” is stored as shown in the image below :

Similar questions