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
Are there constructors in c?
Why main is used in c?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
Can we add pointers together?
can we change the default calling convention in c if yes than how.........?
using only #include
What is keyword in c?
What is a union?
If null and 0 are equivalent as null pointer constants, which should I use?
What is a shell structure examples?
Explain how can I make sure that my program is the only one accessing a file?
Is c procedural or object oriented?
When do we get logical errors?
write a c program for swapping two strings using pointer
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only