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

Answer Posted / suraj bhan gupta

#inclue<stdio.h>
#include<string.h>
main(){
char a[10],i;
int len=1;
printf(" Enter string ");
fgets(a,9,stdin);

len = strlen(a);


for(i=0 ; i<(len/2) ; i++){
a[i]=a[i]+a[len-2];
a[len-2]=a[i]-a[len-2];
a[i]=a[i]-a[len-2];
len--;
}
printf("\n Reverse string with n/2 complexity
%s",a);
return 0;
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

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

2261


What is full form of PEPSI

2134


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

4065


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

2033


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

3293


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

4080


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

3395


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

1301


How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

2175


why nlogn is the lower limit of any sort algorithm?

2554


Write a routine to implement the polymarker function

4593


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

3284


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2578


Write a program to model an exploding firecracker in the xy plane using a particle system

3883


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

3353