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 a char in c?
What is the method to save data in stack data structure type?
What is c mainly used for?
Where is c used?
When should volatile modifier be used?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
Explain how are portions of a program disabled in demo versions?
What is sizeof return in c?
Explain how do you search data in a data file using random access method?
What is spark map function?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
What is 'bus error'?
Define Array of pointers.
Is c# a good language?
Which control loop is recommended if you have to execute set of statements for fixed number of times?