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



Write a code to reverse string seperated by spaces i/p str=India is my country o/p str=aidnI si ym..

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

Post New Answer

More C Interview Questions

In C program, at end of the program we will give as "return 0" and "return 1", what they indicate? Is it mandatory to specify them?

5 Answers  


Why array starts with index 0

2 Answers  


What is a macro in c preprocessor?

0 Answers  


#include<stdio.h> { printf("Hello"); } how compile time affects when we add additional header file <conio.h>.

0 Answers  


What is the use of linkage in c language?

0 Answers  


enum day = { jan = 1 ,feb=4, april, may} what is the value of may? a)4 b)5 c)6 d)11 e)none of the above

8 Answers   HCL, Wipro,


What is const volatile variable in c?

0 Answers  


a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.

0 Answers  


how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....

0 Answers  


what is difference between array and structure?

44 Answers   College School Exams Tests, CTS, Google, HCL, IBM, Motorola, TCS,


Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +

1 Answers  


what is stack , heap ,code segment,and data segment

0 Answers  


Categories