[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.
Interview Questions and Answers :: Alcatel-Lucent

3. write a program to reverse all the word in given sentence .
Ex. India is a Great Country.
Output: aidni si a taerg yrtnuoc.

Answer:

reverseWordString ( char * str)
{
int len, i, j;
len = strlen(str);
j = 0;
for (i = 0;i < len; i++)
if ( str[i] == ' ')
{
swap (str, j, i-1)
j = i+1;
}

void swap(char *str1, int start, int end)
{
int i = start;
char tmp;
for ( ; i<=end; i++, end--)
tmp = srt1[i];
str1[i]= str[end];
str[end] = tmp;
}

Post Your Answer Here:      Public      Private

Rate This: +2 -0
Report     

Post Your Reply Here:     

Report Error

Report Error

Please Login First Click Here