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 |
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
How. To pass the entrance test
What does & mean in scanf?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
Explain what is the use of a semicolon (;) at the end of every program statement?
I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
Are the outer parentheses in return statements really optional?
What are local static variables?
Which is best linux os?
What is array of pointers to string?
When should the register modifier be used? Does it really help?