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...

String reverse with time complexity of n/2 with out using
temporary variable.

Answer Posted / raghuram

#include<iostream.h>

#include<string.h>//complexity-n/2

int main()
{
int i,l,l1;
char str[100];
cout<<"enter string:";
gets(str);
l=strlen(str);
if(l%2==0)
l1=(l/2-1);
else
l1=l/2;
for(i=0;i<=l1;i++)/*swap elements from 2 ends till u reach
middle part of array*/
{
char t=str[i];
str[i]=str[l-i-1];
str[l-i-1]=t;
}
str[l]=0;
cout<<"\n\nreversed string is:"<<str;
getch();
return 0;
}

Is This Answer Correct ?    2 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is data _null_? ,Explain with code when u need to use it in data step programming ?

3275


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

2617


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1573


write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30

2643


Cluster head selection in Wireless Sensor Network using C programming language.

3675


could you please send the program code for multiplying sparse matrix in c????

3525


What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

2862


Develop a routine to reflect an object about an arbitrarily selected plane

3553


write a simple calculator c program to perform addition, subtraction, mul and div.

3676


How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?

2492


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2720


Design an implement of the inputs functions for event mode

3453


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

3301


how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3598


What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?

4438