Given an array of characters, how would you reverse it? How
would you reverse it without using indexing in the array?
Answer / abdur rab
#include <stdio.h>
void reverse ( char* cp_str )
{
char* cp_rev_ptr = NULL;
cp_rev_ptr = cp_str;
while ( ( cp_rev_ptr ) && ( *cp_rev_ptr != '\0' ) )
cp_rev_ptr++;
cp_rev_ptr--;
while ( cp_str < cp_rev_ptr ) {
*cp_str ^= *cp_rev_ptr ^= *cp_str ^=
*cp_rev_ptr;
cp_str++;
cp_rev_ptr--;
}
}
int main ( int argc, char* argv [] )
{
char array [] = {"dlroW olleH"};
printf ("\nBefore :%s", array );
reverse ( array );
printf ("\nAfter :%s", array );
return ( 0 );
}
Output
======
Before :dlroW olleH
After :Hello World
Is This Answer Correct ? | 16 Yes | 5 No |
what are the advantage and disadvantage of recursion
write a program to concatenation the string using switch case?
1)what are limitations for recursive function? 2)write a program to read a text file and count the number of characters in the text file
What is the advantage of a random access file?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Explain what is the difference between text files and binary files?
What are the different types of C instructions?
Find the O/p of the following 1) #include int main() { char c='1'; int j=atoi(c); }
How to implement variable argument functions ?
Find string palindrome 10marks
5 Answers Honeywell, Infosys, Riktam, Roland,
In a byte, what is the maximum decimal number that you can accommodate?