pgm in c to reverse string by word using array(god is love
becomes love is god)
(no additional array can used,space is only delimiter
between words )
Answer Posted / vaibhav srivastava
#include<stdio.h>
int main()
{
char str[50];
int i,j,k;
printf("\nEnter the string\t");
fflush(stdin);
gets(str);
puts(str);
for (i=0; str[i]!='\0';i++);
for ( k=i; k>0; k--)
{ if ( str[k]==' ' || k==i)
{ for( j=k-1; (str[j]!=' ') && (j!=-1) ;j--);
{
while ( ++j!=k)
{printf("%c", str[j]);}
printf(" ");
}
}
}
printf("\n");
}
Is This Answer Correct ? | 22 Yes | 3 No |
Post New Answer View All Answers
What is the scope of static variables in c language?
Explain threaded binary trees?
Write a program to swap two numbers without using the third variable?
Is r written in c?
What is null in c?
When can a far pointer be used?
What are the features of the c language?
Differentiate between Macro and ordinary definition.
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
Can you think of a logic behind the game minesweeper.
What are header files in c?
Can the sizeof operator be used to tell the size of an array passed to a function?
What will the code below print when it is executed? int x = 3, y = 4; if (x = 4) y = 5; else y = 2; printf ("x=%d, y=%d ",x,y);
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What does volatile do?