A palindrome number is a number that remains the same when its digits are reversed. Like 16461, for example, is a palindrome num ber .Write a Program to generate the Palindrome numbers between 1 and 200 in an output file named "palindrome.txt" .
1 answer:
Answer:
Code is given below and output is attached as an image.
Explanation:
#include <iostream>
#include <fstream>
using namespace std;
bool isPalindrome(int n)
{
// Find reverse of n
int rev = 0;
for (int i = n; i > 0; i /= 10)
rev = rev * 10 + i % 10;
// If n and rev are same,then n is a palindrome
return (n == rev);
}
int main()
{
int min = 1; // Lower Bound
int max = 200; // Upper Bound
ofstream myfile;
myfile.open("palindrome.txt");
for (int i = min + 1; i < max; i++)
if (isPalindrome(i))
myfile << i << endl;
myfile.close();
return 0;
}
You might be interested in
Answer:
3rd one
Explanation:
took test
Which formula contains an absolute cell reference? =SUM($B$7:$B$9)
Answer:
i just got my new pc
Explanation:
Answer:
Intra role Conflict
Explanation:
Intra role conflict basically talks about expectations from a role sender on how to go about a particular task clashing with the behavior the person that received the role is exhibiting