To reverse the digits, you mean? I would convert to a StringBuffer, and use the built-in reverse() method to reverse it.
If you want to program this yourself, because that is what a teacher wants, get the last digit and print it out (or add it to a string); then divide the number by 10, and again get the last digit of the result (which is the second-last digit from the original number), and continue until you have naught left. To get the last digit, use the "%" operator:
myNumber % 10
This will give you the remainder of the division by 10.
To reverse the digits, you mean? I would convert to a StringBuffer, and use the built-in reverse() method to reverse it.
If you want to program this yourself, because that is what a teacher wants, get the last digit and print it out (or add it to a string); then divide the number by 10, and again get the last digit of the result (which is the second-last digit from the original number), and continue until you have naught left. To get the last digit, use the "%" operator:
myNumber % 10
This will give you the remainder of the division by 10.
To reverse the digits, you mean? I would convert to a StringBuffer, and use the built-in reverse() method to reverse it.
If you want to program this yourself, because that is what a teacher wants, get the last digit and print it out (or add it to a string); then divide the number by 10, and again get the last digit of the result (which is the second-last digit from the original number), and continue until you have naught left. To get the last digit, use the "%" operator:
myNumber % 10
This will give you the remainder of the division by 10.
To reverse the digits, you mean? I would convert to a StringBuffer, and use the built-in reverse() method to reverse it.
If you want to program this yourself, because that is what a teacher wants, get the last digit and print it out (or add it to a string); then divide the number by 10, and again get the last digit of the result (which is the second-last digit from the original number), and continue until you have naught left. To get the last digit, use the "%" operator:
myNumber % 10
This will give you the remainder of the division by 10.
class Reverse{
public static void main(String args[]){
int num=0,rem=0,rev=0;
Scanner sc=new Scanner(System.in);
System.out.println("ENTER THE NUMBER TO BE REVERSED:");
num=sc.nextInt();
do{
rem=num%10;
rev=rev+(rem*10);
num=num/10;
}while(num!=0);
System.out.println("REVERSE OF THE NUMBER IS:"+rev);
}
}
To reverse the digits, you mean? I would convert to a StringBuffer, and use the built-in reverse() method to reverse it.
If you want to program this yourself, because that is what a teacher wants, get the last digit and print it out (or add it to a string); then divide the number by 10, and again get the last digit of the result (which is the second-last digit from the original number), and continue until you have naught left. To get the last digit, use the "%" operator:
myNumber % 10
This will give you the remainder of the division by 10.
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<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }
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.
//This function reverse any given string, except nullstatic string Reverse(string s) {char[] temp = s.ToCharArray();Array.Reverse(temp);return new string(temp);}//The main usagestring inputString = Console.ReadLine();Console.WriteLine(Reverse(inputString));
write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)
.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......
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<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }
reverse programe in fox pro
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.
Reverse the string and compare it to the original. If they match, then it is a palindrome.
//This function reverse any given string, except nullstatic string Reverse(string s) {char[] temp = s.ToCharArray();Array.Reverse(temp);return new string(temp);}//The main usagestring inputString = Console.ReadLine();Console.WriteLine(Reverse(inputString));
8086 assembly language program to check wether given number is perfect or not
write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)
Halv that given number,Make a square that has that half number as the length of a side.Stretch the string across the diagonal of the square from corner to corner.The length of the string is the square root of the given number
Use for loop declare string array str[] and string variable l= string length of string array j=l for i=0 to i=l/2 then temp=str[i] str[i]=str[j-1] str[j-1]=temp j=j-1 now print str array it will be reversed
/*We can calculate this with a lot of methods I'll explain only one of them */ *str = "abcd"; // this is a input string printf("%d", strlen(str));
.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......
a promlem to solve an equation or a assigment