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 are high level languages like C and FORTRAN also known as?
how to count no of words,characters,lines in a paragraph.
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
how do you execute a c program in unix.
What is the use of function in c?
How do I use void main?
List the difference between a "copy constructor" and a "assignment operator"?
What are 3 types of structures?
What is nested structure?
What does malloc () calloc () realloc () free () do?
can any one provide me the notes of data structure for ignou cs-62 paper
Why isnt any of this standardized in c?
What are variables c?
What is the difference between strcpy() and memcpy() function in c programming?
What is variable initialization and why is it important?