Q13. Write a C program to reverse a word.

Also interviewer can ask  to write a C program to reverse a string. In below program we give input “welcome to gyantoday” Then output will be “yadotnayg ot emoclew” .

Lets reverse “gyantoday”



void reverse_word(char *str)


int i, length;

char temp;

length = strlen(str);

for (i = 0; i < length/2; i++)


temp = *(str+i);

*(str+i) = *(str+length-i-1);

*(str+length-i-1) = temp;



int main()


char word[] = “gyantoday”;



return 0;





Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.