Write a function which takes a character array as input and
reverses it in place.
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / arun
#include<iostream>
using namespace std;
void reverse(char *a)
{
char *tmp = new char[strlen(a)];
memset(tmp,0,strlen(tmp));
int a1 = strlen(a);
a1 =a1-1;
for (int i = a1;i>=0; i--)
{
tmp[a1-i] = a[i];
}
cout<<tmp<<" "<<strlen(tmp)<<endl;
}
void main()
{
char *name = "Xerox";
reverse(name);
}
Is This Answer Correct ? | 2 Yes | 2 No |
when can we use copy constructor?
What is expression parser in c++
What is function overloading in C++?
Why we use #include iostream in c++?
What will happen if when say delete this ?
How many storage classes are available in C++?
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.
Write about the members that a derived class can add?
wrong statement about c++ a)code removably b)encapsulation of data and code c)program easy maintenance d)program runs faster
What is a dll entry point?
How the compilers arranges the various sections in the executable image?
Write a program in C++ for Fibonacci series
0 Answers Axtria, ITC Indian Tobacco Company,