pgm to reverse string using arrays i.e god is love becomes
love is god)
(assumption:only space is used for seperation of words)
no addtional memory used.i.e no temporary arrays can used.
Answer Posted / santhi perumal
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,length;
char a[] = "god is love";
length = strlen(a);
printf("The Given String is\n%s\n",a);
printf("The Resulted String is\n");
for(i=length-1;i>=0;i--)
{
if(a[i] == ' ')
{
for(j=i+1; a[j] != ' ' && a[j] != '\0';j++)
{
printf("%c",a[j]);
}
printf("%c",a[i]);
}
}
i++;
while(a[i] !=' ')
{
printf("%c",a[i]);
i++;
}
printf("\n");
}
| Is This Answer Correct ? | 14 Yes | 2 No |
Post New Answer View All Answers
How can I prevent another program from modifying part of a file that I am modifying?
What are unions in c?
Why c is called procedure oriented language?
What does the file stdio.h contain?
What is an lvalue?
Is register a keyword in c?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
How does normalization of huge pointer works?
Can we increase size of array in c?
What are data structures in c and how to use them?
How can I sort a linked list?
What is the purpose of & in scanf?
Can you please explain the difference between strcpy() and memcpy() function?
What do you understand by normalization of pointers?
Describe how arrays can be passed to a user defined function