answersLogoWhite

0

#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

7y ago

What else can I help you with?

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 c program to find out the prime numbers between 1 to 500?

To write a C program to find prime numbers between 1 to 500, you can use a nested loop structure. In the outer loop, iterate from 2 to 500, and in the inner loop, check if the number is divisible by any number from 2 to the square root of the number. If it is not divisible by any number other than 1 and itself, then it is a prime number. Print out all prime numbers found within the specified range. Remember to include necessary header files, such as &lt;stdio.h&gt;, and use appropriate logic to implement the program efficiently.


What is c plus v and d?

C=100, V=5, D=500


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"); } } } }

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.


What is the palindrome for the Indy 500 vehicle?

Racecar


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.


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


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


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.


Lcm of 100 and 125?

LCM is least common multiple of two or more numbers. LCM of 100 and 125 is 500.