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 |
Explain RAII (Resource Acquisition Is Initialization).
Can constructor be static in c++?
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
print first nodd numbers in descending order
Is swift a good first language?
Which one between if-else and switch is more efficient?
what is the use of void main() in C++ language?
State the difference between delete and delete[].
Why null pointer is used?
What are multiple inheritances (virtual inheritance)? What are its advantages and disadvantages?
What is pointer with example?
What are virtual constructors/destructors?