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 |
How size of a class can be calulated?
What is the most useful programming language?
What are keywords in c++?
Tell me difference between constant pointer and pointer to a constant.
What is abstraction in c++ with example?
What is implicit conversion/coercion in c++?
Explain polymorphism?
a class that maintains a pointer to an object that is programatically accessible through the public interface is known as?
What is c++ and its features?
Explain the concept of inheritance in C++.
What are the advantages of early binding?
Comment on local and global scope of a variable.