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

Answer Posted / manish pathak

//********this is perfect answer***************

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,num,rem,l;
char s[]="abcde";
l=sizeof(s)-1;
for(i=0,j=l-1;i<=(l-1)/2;i++)//save space n/2
{

s[i]=s[i]+s[j-i];
s[j-i]=s[i]-s[j-i];
s[i]=s[i]-s[j-i];

}

s[l]='\0';
printf("%s",s);
getch();
}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

3127


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

2923


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.

2233


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 ?

2374


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

2521






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

3260


Sir... please give some important coding questions asked by product companies..

1929


Design an implement of the inputs functions for event mode

3052


How can you relate the function with the structure? Explain with an appropriate example.

3025


Write a routine to implement the polymarker function

4487


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

3145


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

1186


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

3881


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

2334


write a program for area of circumference of shapes

2134