Question

C++ Visual A palindrome number is a number that remains the same when its digits are...

C++ Visual
A palindrome number is a number that remains the same when its digits are reversed. Like 16461, for example, is a palindrome number .Write a Program to generate the Palindrome numbers between 1 and 200 in an output file named "palindrome.txt" .

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
using namespace std;

bool isPalindrome(int num);
   int main()
   {
       //Defines an output stream for the data file
ofstream dataOut;
//creating and Opening the output file
dataOut.open("palindrome.txt");
  
   for(int i=1;i<=200;i++)
   {
       bool b=isPalindrome(i);
       if(b)
       {
           dataOut<<i<<endl;
           }
       }
   dataOut.close();
   return 0;  
   }

//This function will check whether the number is palindrome or not
bool isPalindrome(int num)
{
int n,rev,digit;
n = num;

do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
} while (num != 0);
if (n == rev)
return true;
else
return false;
  
}

___________________________

Output:

______________________Thank You

Add a comment
Know the answer?
Add Answer to:
C++ Visual A palindrome number is a number that remains the same when its digits are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Palindrome Write a program that prompts the user for a positive integer number and output whet...

    Language is C 1. Palindrome Write a program that prompts the user for a positive integer number and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversed. For example, 12321 is a palindrome; 1234 is not a palindromoe. You will write a function named as palindrome. The function will have two arguments, number and isPalindrome. Both arguments are pass-by-reference. The argument number is a pointer to a variable...

  • (1 point) A palindrome is a number (like 535) that is the same if the digits...

    (1 point) A palindrome is a number (like 535) that is the same if the digits are written in reverse order. If a number is a three digit multiple of eleven then the probability that it is a palindrome is

  • This is a java question A palindrome is a word or phrase that reads the same...

    This is a java question A palindrome is a word or phrase that reads the same forward and backward, ignoring blanks and punctuations, and considering uppercase and lowercase versions of the same letter to be equal. For example, the following are palindromes: warts n straw radar Able was I ere I saw Elba tacocat Write a program named Palindrome.java that will accept a file (file name) from the command argument list and decide whether each line in the file is...

  • PLEASE USE MATLAB AND LOOP STATEMENTS TO SOLVE THE FOLLOWING PROBLEM: Write a function called palindrome...

    PLEASE USE MATLAB AND LOOP STATEMENTS TO SOLVE THE FOLLOWING PROBLEM: Write a function called palindrome that receives a whole number as input and returns true if the number is palindromic, and returns false otherwise. Recall that number is palindromic if it remains the same when the order of its digits is reversed. Examples of palindromic numbers are: 7, 44, 191, 3883, 25052, 617716.

  • 1 of 1 15 points) Palindrome Detector. A palindrome is a phrase that reads the Pi...

    1 of 1 15 points) Palindrome Detector. A palindrome is a phrase that reads the Pi same ronwards as it does backwards. For example, "a man, a plan, a canal, Panama is a palindrome. Write a program that uses a stack to check for palindromes in each line of a text file. Try your program on the example text file "palindromes txt".Your program should output the palindromes that it finds in the document. For example: FindPalindromes( palindromes.txt") will display "a...

  • Problem 1. A palindrome is a sequence of characters that reads the same backward as forward....

    Problem 1. A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Problem 2. Modify the program to determine whether a seven-digit number...

  • in a c++ visual studio 2017 ...Write a program that simulates a lottery. The program should...

    in a c++ visual studio 2017 ...Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range 0 through 9 for each element in the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding element in the two arrays and keep a count of the digits that match. For...

  • A palindrome is a number or a text phrase that reads the same backward as forward....

    A palindrome is a number or a text phrase that reads the same backward as forward. For example, each of the following six-digit integers is a palindrome: 123321, 555555, 455554, and 116611. Write a pseudocode and C++ program that reads in a six-digit integer and determines whether or not it is a palindrome. You must use the division and remainder operators. Assume input is correct (six-digit integer). Please don't use loops. Do it with only using if else.

  • Palindrome is a word or a phrase when taken in reverse order, gives the same word...

    Palindrome is a word or a phrase when taken in reverse order, gives the same word or phrase. For example, the word “radar” is a palindrome. The phrase "Do geese see God?" is also a palindrome after the removal of the question mark and all the spaces and the conversion of the remaining alphabets to either upper or lower case. Write a program that uses an STL stack to check if an arbitrary string containing multiple words separated by spaces...

  • Using C language Palindromes A palindrome is a word or phrase that reads the same backwards...

    Using C language Palindromes A palindrome is a word or phrase that reads the same backwards and forwards, ignoring punctuation, spaces, and anything that isn’t a letter. Examples of Palindromes Madam, I’m Adam. Kayak Racecar A man, a plan, a canal – Panama! Able was I, ere I saw Elba. Go hang a salami, I’m a lasagna hog! Write a program that does the following: opens a text file named “Proj3input.txt” containing multiple lines of text (1 or more) for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT