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
What does int main () mean?
Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.
What are the preprocessor categories?
What is graph in c?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
How can you avoid including a header more than once?
Explain the difference between the local variable and global variable in c?
How can I find the modification date and time of a file?
what are the advantages of a macro over a function?
C language questions for civil engineering
write a program to find the given number is prime or not
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
Is javascript written in c?
What is c language used for?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?