---
title: "Write a program for reverse a word in sentence in any programming language."  
description: "Write a program for reverse a word in sentence in any programming language."  
author: "Mukul Goenka"  
published: 2021-11-07  
updated: 2021-11-07  
canonical: https://www.mindstick.com/forum/156801/write-a-program-for-reverse-a-word-in-sentence-in-any-programming-language  
category: "c#"  
tags: ["c#", ".net", "java"]  
reading_time: 1 minute  

---

# Write a program for reverse a word in sentence in any programming language.

Write a [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) for [reverse](https://www.mindstick.com/blog/63740/what-are-the-most-effective-and-safest-thanks-to-reverse-erectile-dysfunction) a [word](https://www.mindstick.com/forum/305/read-word-file) in sentence in any [programming language](https://www.mindstick.com/articles/329035/5-most-in-demand-programming-languages-to-consider-for-your-app-development-in-2022).

## Replies

### Reply by Ravi Vishwakarma

Let me explain the reverse a word in sentence.

```
Input: s = 'the sky is blue'
Output: 'blue is sky the'
```

## Program

```
#include <stdio.h>
void reverse(char* begin, char* end)
{
 char temp;
 while (begin < end) {
 temp = *begin;
 *begin++ = *end;
 *end-- = temp;
 }
}
void reverseWords(char* s)
{
 char* word_begin = s;
 char* temp = s;
 while (*temp) {
 temp++;
 if (*temp == '\0') {
 reverse(word_begin, temp - 1);
 }
 else if (*temp == ' ') {
 reverse(word_begin, temp - 1);
 word_begin = temp + 1;
 }
 }
 reverse(s, temp - 1);
}
// Driver Code
int main()
{
 char str[] = 'Hi, I am a software developer in java language?';
 char *ptrStr = str;
 reverseWords(str);
 printf('%s', str);
 return 0;
}
```

## Output:

```
language? java in developer software a am I Hi,
```


---

Original Source: https://www.mindstick.com/forum/156801/write-a-program-for-reverse-a-word-in-sentence-in-any-programming-language

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
