answersLogoWhite

0

How do you print the revers string?

Updated: 8/10/2023
User Avatar

Wiki User

13y ago

Best Answer

u got a String A

String B stores the reverse

A="John"

use a reverse loop.

for(int i=A.length();i>0;i--)
{
p=A.charAt(i);
B=B+p;
}

thats it u got the reverse in B


In Java, you can just use the build-in method of the class StringBuffer.

User Avatar

Wiki User

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

Wiki User

13y ago

Here you go....

#include<stdio.h>

#include<conio.h>

#define pf printf

#define sf scanf

void main(void)

{

int j,n,line;

clrscr();

pf("\nEnter number of lines\n");

sf("%d",&n);

for(line=n;line>=1;line--)

{

for(j=0;j<(n-line);j++)

putchar(' ');

for(j=1;j<(2*(line-1));j++)

pf("%d",j);

pf("\n");

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

printf, fprintf, puts, fputs, fwrite... it's not the printing but the reversing what is tricky

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you print the revers string?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you Print all the first characters in the string in python programming?

Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!


How do you print a string 5 times in java?

For(int I = 0: I &lt; 5; i++) { System.out.println(" print this " + I ); }


What converts print jobs generated by applications into a string of commands for a specific print device?

Printer driver


What ConsoleWriteLine do when NULL character within a string?

it will print nothing on commandline..


What are the components of print f and scan f?

printf: format string + value list scanf: format string + address list


How would you write this in Python Assume that word is a string for example slice Write a code to print out the following pattern s sl sli slic slice?

&gt;&gt;&gt; string = 'slice' &gt;&gt;&gt; letters = list(string) &gt;&gt;&gt; print letters ['s', 'l', 'i', 'c', 'e'] &gt;&gt;&gt; string2 = '' &gt;&gt;&gt; for letter in letters: string2 += letter print string2 s sl sli slic slice


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


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

console.wrikerle("""");


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


Why printf is used instead of print in c?

The printf() function prints a formatted string.


Take input of string reverse the strring in python?

There are five common methods of string inversion in Python: using string slicing, using recursion, using the list reverse () method, using stack and using for loop. Use string slicing (most concise) s = &quot;hello&quot; reversed_ s = s[::-1] print(reversed_s) &gt;&gt;&gt; olleh Use recursive def reverse_ it(string): if len(string)==0: return string else: return reverse_ it(string[1:]) + string[0] print &quot;added &quot; + string[0] string1 = &quot;the crazy programmer&quot; string2 = reverse_ it(string1) print &quot;original = &quot; + string1 print &quot;reversed = &quot; + string2 Use the list reverse() method in [25]: l = ['a', 'B', 'C','d '] ...: l.reverse() ...: print (l) ['d', 'c', 'b', 'a'] Using stack def Rev_ string(a_string): L = list (a_string) # simulate all stacking new_ string = &quot;&quot; while len(l)&gt;0: new_ String + = l.pop() # simulate stack out return new_ string Use the for loop #for loop def func(s): r = &quot;&quot; max_ index = len(s) - 1 for index,value in enumerate(s): r += s[max_index-index] return r r = func(s) The above are the five common methods of string inversion in Python. I hope it can be helpful to your learning of Python strings


Is in the movie date night is it put your truck in revers or put your junk in revers?

haha PUT YO JUNK IN REVERSE!