Write a function which takes a character array as input and
reverses it in place.

Answer Posted / gumnam

void reverse(char *a)
{
char tmp;
int len = strlen(a) - 1;

for (int i = 0; i < len/2; i++)
{
tmp = a[i];
a[i] = a[len - i];
a[len - i] = tmp;
}
}

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain linear search.

637


Which c++ compiler is best?

593


How can I learn c++ easily?

627


What is decltype c++?

559


What relational operators if statements in c++?

646






Why do we use using namespace std in c++?

605


What are associate containers?

619


Why pointer is used in c++?

620


What are put and get pointers?

587


What are the advantages of c++?

599


How many types of modularization are there in c++?

567


When one must use recursion function? Mention what happens when recursion functions are declared inline?

653


Explain this pointer?

587


What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random

661


What are the advantages of inheritance in c++?

659