answersLogoWhite

0


Best Answer

#include<iostream>

// forward declarations...

unsigned reverse (unsigned, const unsigned base = 10);

bool is_palindrome (const unsigned);

// the program...

int main (void) {

const unsigned max {500};

const unsigned min {100};

std::cout << "Palindromes from " << max << " to " << min << std::endl;

for (unsigned num {max}; num>=min; --num) {

if (is_palindrome (num)) {

std::cout << num << std::endl;

}

}

}

// Returns the reverse of a number using the given base (default: base 10)

// Note: trailing zeroes do not become leading zeroes so reverse (100) returns 1 not 001.

// However, the reverse of 0 is obviously 0.

unsigned reverse (unsigned num, const unsigned base /* = 10 */) {

unsigned rev {}; // zero-initialised

while (num) {

rev *= base;

rev += num % base;

num /= base;

}

return rev;

}

// If the reverse of a number is the same number, that number is a palindrome.

// All single-digit numbers are palindromes, including 0.

bool is_palindrome (const unsigned num) {

return num == reverse (num) ;

}

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the program for palindrome numbers from 500 to 100?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program in Java which will print all nested loop between 1 to 500?

Sure! Here's a Java program that will print all the nested loops between 1 to 500: public class NestedLoopExample { public static void main(String[] args) { for (int i = 1; i &lt;= 500; i++) { for (int j = 1; j &lt;= 500; j++) { System.out.println(&quot;i=&quot; + i + &quot;, j=&quot; + j); } } } } This program uses two nested for loops to iterate from 1 to 500. It prints the value of i and j for each iteration of the loops.


What is the total impedance of a series circuit that has 100 Ω resistance 500 Ω of inductive reactance and 300 Ω of capacitive reactance?

It is 100+j(500-300) ohm = (100+j200) ohm = 223.6&lt;630 ohm


Write a program to print automorphic numbers between 1 and 100?

import java.math.*; import java.util.*; class AutomorphicNumber{ static int d=10; public static void main(String args[]){ System.out.print("Enter any number :"); Scanner input=new Scanner(System.in); int n=input.nextInt(); if(d&gt;=n){ if ((n*n) % d == n){ System.out.println("Automorphic Number"); } else{ System.out.println("Not Automorphic Number"); } } else if(d&lt;=n){ d=d*10; if ((n*n) %d==n){ System.out.println("Automorphic Number"); } else{ System.out.println("not an automorphic number"); } } } }


What is c plus v and d?

C=100, V=5, D=500


Program to generate a Pythagorean triplets using C sharp?

well you could go with something like this (this code gives you all triples within a &lt; 500 and b &lt; 500): --------------------------------------------- for (int i = 0; i &lt; 500; i++) for (int j = 0; j &lt; 500; j++) { double squareroot = Math.Sqrt(i*i + j*j); if (squareroot == Math.Round(squareroot)) { // i, j and squareroot is your triple. Add them to list or what ever. } }

Related questions

What are the next numbers in the pattern in 20 20 100 100 500?

500 2500.


How many time does 5 into 500?

100 times because if you do the opposite with the numbers you have, 500/5=100


What are the numbers that will equal 500 rounded to the nearest 100?

500


How many numbers between 100 and 500 end in a 5?

40. There are 400 numbers between 100 and 500 and one in every ten ends in 5.


Which 5 consecutive whole numbers have a mean of 100?

Well First, you need 500 because 500/5 is obviuosly 100. 98+99+100+101+102= 500. Therefore, the consecutive whole numbers are 98,99,100,101,102! -Levizy123


What is the mean of 100 300 500 500 600?

100 + 300 + 500 + 500 + 600 = 2000. Then divide by 5 to get 400. The mean of these five numbers is 400.


How many 3 digit numbers are under 500?

The 3 digit numbers under 500 are 100 through 499.


What are the greatest and least numbers that round to 500 when rounded to the nearest 100?

500


What is the palindrome for the Indy 500 vehicle?

Racecar


How mane odd numbers between 100 and 1000?

500


How many integers between 100 and 500 are divisible by 6 but not 8?

There are (500-100)/2 = 200 numbers divisible by 2 between 100 and 500 counting 100 but not 500. Of these (500-100)/8 = 50 are divisible by 8. So there are 150 numbers between 100 and 500 divisible by two but not by 8. By relative primeness exactly 50 out of these 150 are divisible by 3 and therefore these 50 are exactly the ones divisible by 6 but not by 8.


How do you figure out percentages of odd numbers?

Multiply them by 100 - as you would with even numbers. So 5, as a percentage is 5*100 = 500%