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
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
where are auto variables stored? What are the characteristics of an auto variable?
What does the error 'Null Pointer Assignment' mean and what causes this error?
What are inbuilt functions in c?
Can the size of an array be declared at runtime?
What is null pointer in c?
What is c mainly used for?
Differentiate between a structure and a union.
What are the rules for the identifier?
What are the different categories of functions in c?
What is union and structure in c?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
What's a good way to check for "close enough" floating-point equality?
Is swift based on c?
How to declare a variable?