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 )
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / charan
#include <stdio.h>
#include <conio.h>
void main()
{
char *str;
char s[10][10];
int i=0,j=0,p=0;
clrscr();
printf("Enter the string");
gets(str);
while(str)
{
if(str[i]!=' ')
s[j][p++]=str[i];
else
{
s[j][p++]='\0';
p=0;
}
i++;
}
for(i=j;i>=0;i--)
puts(s[i]);
getch();
}
Is This Answer Correct ? | 1 Yes | 10 No |
Does free set pointer to null?
What is c variable?
create a C program that displays one z,two y's,three x's until twenty six A's. plzz answer i need it tomorrow.
a simple c program using 'for' loop to display the output 5 4 3 2 1
How to access or modify the const variable in c ?
16 Answers HCL, HP,
find the size of structure without using the size of function
O,T,T,F,F,S,S,E,N,?,?,?,T,F,F,S,S,E,N
What is a stream water?
What are linker error?
char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)
Here is a neat trick for checking whether two strings are equal
how to add numbers without using arithmetic operators.