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 |
write a program wch produces its own source code aas its output?
WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h> #include<conio.h> void main() { int k=20; printf("%d%d%d%d",k,k++,++k,k); getch(); }
what is level of tree if leaf node is at level 4.please explain.
Difference between C and Embedded C?
which will return integer? a) int*s ( ) b) ( int* ) s( ) c) int ( *s ) ( )
Why doesnt long int work?
What is the output of the following program main();{printf ("chennai""superkings"}; a. Chennai b. superkings c. error d. Chennai superkings
Here is a good puzzle: how do you write a program which produces its own source code as output?
print ur name 20,000 times without using inbuilt library functions like printf,scanf,gets,puts,getchar or putchar
What's the difference between struct x1 { ... }; and typedef struct { ... } x2; ?
When should a type cast be used?
whether itis a structured language?