Write a code to reverse string seperated by spaces
i/p str=India is my country
o/p str=aidnI si ym yrtnuoc
After writing code, optimize the code
Answer / laju
#include<stdio.h>
#include<conio.h>
strrev(char *,char *);
void main()
{
clrscr();
char *p,*q;
char str[100];
printf("enter the string");
gets(str);
p=q=str;
while(*q!='\0')
{
if(*q==' ')
{
strrev(p,q-1);
p=q+1;
}
q++;
}
strrev(p,q-1);
puts(str);
getch();
}
strrev(char *p,char *q)
{
char temp;
while(q>p)
{
temp=*q;
*q=*p;
*p=temp;
q--;
p++;
}
}
| Is This Answer Correct ? | 4 Yes | 3 No |
What is the purpose of scanf() and printf() functions?
what are the different storage classes in c?
What is action and transformation in spark?
Disadvantages of C language.
multiple of 9 without useing +,* oprator
What is string concatenation in c?
main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); }
#include<stdio.h> { printf("Hello"); } how compile time affects when we add additional header file <conio.h>.
What is the basic structure of c?
What is the use of the sizeof operator?
In which category does main function belong??
What are keywords c?