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

A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

1180


Explain how do you print an address?

1148


What is ponter?

1272


What are the 4 types of functions?

1061


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

1043


What is an array? What the different types of arrays in c?

1190


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1647


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

1267


how to make a scientific calculater ?

2077


What is the use of putchar function?

1060


What is the difference between volatile and const volatile?

994


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1959


Compare interpreters and compilers.

1074


write a program to find out prime number using sieve case?

2102


What is c++ used for today?

1110