Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can I manipulate strings of multibyte characters?

1257


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

2233


What does main () mean in c?

1146


explain what is an endless loop?

1147


The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration

1155


Can you write the function prototype, definition and mention the other requirements.

1198


How do I determine whether a character is numeric, alphabetic, and so on?

1185


How to compare array with pointer in c?

1169


What is the right type to use for boolean values in c?

1086


Write a program to show the change in position of a cursor using c

1123


Subtract Two Number Without Using Subtraction Operator

906


What are extern variables in c?

1038


Explain how can I convert a number to a string?

1207


What are the uses of a pointer?

1199


How does free() know explain how much memory to release?

1111