answersLogoWhite

0


Best Answer

#include <string.h>

char * revsentence(char *str)

{

int i,j,len;

char temp;

len=0;

len=strlen(str)

for(i=0;j=len-1;i<j;i++,j--)

{

temp=str[i];

str[j]=str[i];

str[j]=temp;

}

return str;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

#include <stdio.h> #include <stdlib.h> #include <ctype.h> #define MAX 100 int main() { char forward_sentence[MAX]; char ch, terminator; int i = 0, j, len = 0; printf("Enter a sentence: "); ch = getchar(); while(i < MAX && ch != '\n' && ch != '.' && ch != '?' && ch != '!') { forward_sentence[i] = ch; i++; len++; ch = getchar(); } for(i = 0; i < MAX; i++) { if(ch == '.') terminator = '.'; else if(ch == '?') terminator = '?'; else if(ch == '!') terminator = '!'; } printf("Reverse of sentence: "); for(j = len - 1; j >= 0; j--) { if(forward_sentence[j] == ' ') { } printf("%c", forward_sentence[j]); } printf("%c", terminator); printf("\n\n"); system("PAUSE"); return 0; }

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you reverse the order of words in a sentence in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the use of Reverse String in C program?

The use of the reverse string in C program is used to reverse the letters in the string. An example would be reverse me would be reversed to em esrever.


How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include&lt;string&gt; using std::string; string reverse (const string&amp; s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout &lt;&lt; "Enter a number: "; string s {}; std::cin &gt;&gt; s; std::cout &lt;&lt; "The number in reverse is: " &lt;&lt; reverse (s); }


Write a flowchart of reverse the string in c?

wefwfe


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


What is the codes for 4 numbers that sort from highest to lowest turbo c plus plus?

Use an associative container such as std::set and enumerate in reverse order, or supply a predicate that sorts in descending order such as std::greater&lt;T&gt; (default is std::less&lt;T&gt;).

Related questions

In inversion a chromosomal fragment breaks free and reattaches itself?

c. in reverse order


Why is karate spelled with a k not a c?

Karate is spelled with a &quot;k&quot; due to its origin in Japan, where the native language uses the &quot;k&quot; sound instead of the &quot;c&quot; sound used in English. The Japanese writing system also does not differentiate between the &quot;k&quot; and &quot;c&quot; sounds, so &quot;karate&quot; is a more accurate transliteration of the word from Japanese.


What do people put between words in a sentence?

s p a c e s


What sentence has all the words starting with the letter C?

"Can cats catch crafty cockroaches".


What three flats are in e flat major?

Bb, Eb, and Ab--in that order. The order of flats is always B, E, A, D, G, C, F; the order of sharps in the reverse: F, C, G, D, A, E, B.


How do you use consonant in a sentence?

Consonants are used alongside vowels to form words in a sentence. For example, in the sentence &quot;The cat sat on the mat,&quot; the consonants &quot;t,&quot; &quot;c,&quot; &quot;s,&quot; and &quot;m&quot; are used to form the words.


Put these words in order to make a sentence for me use ABCDE letters to put the words in order. A ringoshi B irukashi C erushite D nigamiwa E katabenai?

B irukashi C erushite A ringoshi D nigamiwa E katabenai. (In English: The dirty dishes do not get washed.)


What is the use of Reverse String in C program?

The use of the reverse string in C program is used to reverse the letters in the string. An example would be reverse me would be reversed to em esrever.


What is a sentence with all the words starting with the letter c?

Cat Cannot Control Cam's Camera(:


What is s-v-o-c?

it's the shorthand description of word order in a sentence. subject-verb-object. the "c" might stand for complement, I'm not sure. this is the word order in English.


What are some eight letter words with 1st letter C and 4th letter C and 8th letter C?

According to SOWPODS (the combination of Scrabble dictionaries used around the world) there are 2 words with the pattern C--C---C. That is, eight letter words with 1st letter C and 4th letter C and 8th letter C. In alphabetical order, they are: calcific calcitic


Assuming these words do not appear at the beginning of a sentence is incorrectly capitalized?

Answer this question&hellip; C. Independence Day