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 |
write a program to display the numbers in the following 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4
what is the difference between NULL('\0') and 0?
What are register variables? What are the advantage of using register variables?
What are the preprocessor categories?
program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.
What is information technology.
#include<stdio.h> int main( ) { Int a=300, b, c; if(a>=400) b=300; c=200; printf(“%d%d ”, b, c); return0; }
Write a C program to perform some of the operation which can be performed using Single linked list
What kind of structure is a house?
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
write a program to print infinte number
What is difference between constant pointer and constant variable?