answersLogoWhite

0


Best Answer

#include

#include

void pr_reverse(char *s);

int main(void)

{

pr_reverse("I like C");

return 0;

}

void pr_reverse(char *s)

{

register int i;

for(i = strlen(s) - 1; i >= 0; i--)

putchar( s [ i ] );

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

//reverse a string using pointers

# include<stdio.h>

# include<string.h>

void main()

{

char *first,*last;

char temp;

int len;

char str[20];

printf("enter ur string to be reverse: ");

gets(str);

len=strlen(str);

first=str; //point at first character

last=&str[len-1]; //point at last character

for(int i=0;i<=len/2;i++)

{

temp=*first;

*first=*last;

*last=temp;

first++;

last--;

}

puts(str);

}

//BY..RAJAT JAIN

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How to Reverse a string letter by letter in C language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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.


How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include&lt;string&gt; using std::string; string reverse (const string&amp; s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout &lt;&lt; "Enter a number: "; string s {}; std::cin &gt;&gt; s; std::cout &lt;&lt; "The number in reverse is: " &lt;&lt; reverse (s); }


What is literal in c language?

a string constant


Write a flowchart of reverse the string in c?

wefwfe


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension

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.


How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include&lt;string&gt; using std::string; string reverse (const string&amp; s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout &lt;&lt; "Enter a number: "; string s {}; std::cin &gt;&gt; s; std::cout &lt;&lt; "The number in reverse is: " &lt;&lt; reverse (s); }


What is literal in c language?

a string constant


Write a flowchart of reverse the string in c?

wefwfe


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


Why null is used as capital letter in c language?

Null is not a capital letter. It is not any letter. It is a null, '\0', (most often 0x00) and that is a special character, usually indicating the end of a string.


Special character in C language?

special character in c language are as follows~ ' ! @ # % ^ &amp; * () _ - + = | \ {} [] : ; " &lt;&gt; , . ? /


How to Program for reversal of string ven123kat in c?

#include #include #include int reverse(int i);char st[]="ven123kat";void main() {printf("\nThe string is: %s", st);reverse(0);printf("\nReversed string is: %s", st);getch();}int reverse(int i) {if (i


Definition of buffer in assembly language?

its just like a string of c++


How do you make a program to reverse nummber in c language?

I'd use sprintf (assuming the number wasn't a string already) and pointers. If that's not enough of a clue, you're really not ready to be in this programming class.


How you can convert from string to int in C language?

Use the atoi() or atol() function.


How print the string with double cot in c plus plus language?

console.wrikerle("""");