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
Is fortran faster than c?
Explain how can you check to see whether a symbol is defined?
c language interview questions & answer
Add Two Numbers Without Using the Addition Operator
How to draw the flowchart for structure programs?
What is pass by value in c?
Can a pointer be volatile in c?
What is wrong with this code?
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
What are predefined functions in c?
What is extern keyword in c?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
Why is python slower than c?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
What does c mean before a date?