answersLogoWhite

0


Best Answer

#include <stdio.h>

#include <string.h>

int main()

{

char a[20],arev[20];

int i,len;

printf("Enter a string: ");

scanf("%s",a);

len=strlen(a);

for(i=0;i<len;i++)

{

arev[len-1-i]=a[i];

}

arev[len]='\0';

printf("\nReverse of %s is %s",a,arev);

return 0;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program for reversing a string?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the use of Reverse String in C program?

The use of the reverse string in C program is used to reverse the letters in the string. An example would be reverse me would be reversed to em esrever.


Why and operator can not be used in string of c program?

Any character can be used in string, except for \\0. char example [] = "A&amp;B|C";


C program plus copy of string to another?

strcpy


C plus plus program to perform string manipulation?

You do not need to program string manipulation as it is already part of the standard library. See std::string and std::wstring.


How do you write a c program to find a word in a string?

what is if(!(str[i]==32))


Write a c program using string concept enter a sting and replace the new string in to old string and find no of occurrence?

print c co com comp compu


How do you write a c program to find the smallest word in a string?

what is if(!(str[i]==32))


What is the program to create a string class which stores a string value in c plus plus?

C++ already provides a string class in the C++ standard template library. #include&lt;iostream&gt; #include&lt;string&gt; int main() { using namespace std; string s {"Hello world!"}; cout &lt;&lt; s &lt;&lt; endl; }


C program to copy two strings in to a new string with out using stringcopy in borland c?

You can use so called concatenation of strings:{...string str1 = "something here";string str2 = " and something here";string newStr = str1 + str2;...}


Do I need to write a program to find a substring in a given string in c plus plus?

No.


Can you use scanf to get a string to a c program?

Certainly. That's what sequence %s is good for.


C plus plus program to count digit in a string?

Use the following function to count the number of digits in a string. size_t count_digits (const std::string&amp; str) { size_t count = 0; for (std::string::const_iterator it=str.begin(); it!=str.end(); ++it) { const char&amp; c = *it; if (c&gt;='0' &amp;&amp; c&lt;='9'); ++count; } return count; }