1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KATRIN_1 [288]
3 years ago
13

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" .

Computers and Technology
1 answer:
xxMikexx [17]3 years ago
5 0

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
Create a Rational number class in Java using the same style as the Complex number class created in class.(The in class example c
Elis [28]

Answer:

Explanation:

/*

*    This program adds, subtracts, multiplies, and divides two rational numbers.

*/

public class Main {

  //Main method

   public static void main(String[] args) {

       Rational a = new Rational(3, 4);   // input for first rational number

       Rational b = new Rational(2 , 5);   // input for second rational number

       System.out.println(a + " + " + b + " = " + a.add(b));

       System.out.println(a + " - " + b + " = " + a.sub(b));

       System.out.println(a + " * " + b + " = " + a.mul(b));

       System.out.println(a + " / " + b + " = " + a.div(b));

   }

}

class Rational {

   public Rational(int num, int den) {

      numerator = num;

      denominator = den;

     

      //ensures a non-zero denominator

      if (den == 0)

          den =1;

     

      //stores a negative sign in numerator

      if (den < 0) {

          num = num * -1;

          den = den * -1;

      }

   }

   //return numerator

   public int getNumerator() {

     

      return numerator;

   }

 

   //return denominator

   public int getDenominator() {

     

      return denominator;

   }

 

   //return reciprocal method

   public Rational reciprocal() {

     

      return new Rational(denominator, numerator);

   }

   /*   Addition Class

    *        Find common denominator by multiplying the denominators

    *        Store number values (numerator / common denominator) as num1 and num2

    *        Sum both numbers

    */

   public Rational add(Rational r2) {

      int comDen = denominator * r2.getDenominator();

      int num1 = numerator * r2.getDenominator();

      int num2 = r2.getNumerator() * denominator;

      int sum = num1 + num2;

      return new Rational (sum, comDen);

   }

   //Subtraction Class - same implementation as Addition Class

   public Rational sub(Rational r2) {

   

     int comDen = denominator * r2.getDenominator();

     int num1 = numerator * r2.getDenominator();

     int num2 = r2.getNumerator() * denominator;

     int difference = num1 - num2;

     return new Rational (difference, comDen);

  }

   

  /*   Multiplication Class

   *        Multiply numerator with r2 numerator

   *        Multiply denominator with r2 denominator

   */

  public Rational mul(Rational r2) {

   

     int num = numerator * r2.getNumerator();

     int den = denominator * r2.getDenominator();

     return new Rational (num, den);

  }

  /*   Divide Class

   *        Multiply number by r2 reciprocal

   */

  public Rational div(Rational r2) {

      return mul (r2.reciprocal());

  }

  /*   toString Method

   *        Returns rational number as a string - in parenthesis if a fraction

   */

  public String toString() {

     

      return (((numerator == 0) ? "0" : ( (denominator == 1) ? numerator + "": "(" + numerator + "/" + denominator + ")")));

 

      /* Logic for toString method

      * if (num == 0) {

              return "0";

          } else {

              if (denominator == 1){

                  return numerator;

              } else {

                  return numerator + "/" + denominator;

              }

      */

   }

  // Declare variables

  private int numerator, denominator;

 

}

output

(3/4) + (2/5) = (23/20)                                                                                                                                      

(3/4) - (2/5) = (7/20)                                                                                                                                      

(3/4) * (2/5) = (6/20)                                                                                                                                      

(3/4) / (2/5) = (15/8)                                                                                                                                      

6 0
2 years ago
Identifying what you will need to review takes place during?
marishachu [46]
It takes places during surveying.

For example, let's say you want to review your own produced game application software, and found out whether it satisfy your consumer or not

Before you conduct the survey, you have to identify what aspect you want to find out from your consumers , such as : Does it have any bug ? Is it challenging enough ? is the graphic good enough ? etc
7 0
3 years ago
Read 2 more answers
1. Print out the string length of s1 2. Loop through characters in s2 with charAt() and display reversed string 3. Compare s2, s
konstantin123 [22]

Answer:

See explaination

Explanation:

public class StringLab9 {

public static void main(String args[]) {

char charArray[] = { 'C', 'O', 'S', 'C', ' ', '3', '3', '1', '7', ' ', 'O', 'O', ' ', 'C', 'l', 'a', 's', 's' };

String s1 = new String("Objected oriented programming language!");

String s2 = "COSC 3317 OO class class";

String s3 = new String(charArray);

// To do 1: print out the string length of s1

System.out.println(s1.length());

// To do 2: loop through characters in s2 with charAt and display reversed

// string

for (int i = s2.length() - 1; i >= 0; --i)

System.out.print(s2.charAt(i));

System.out.println();

// To do 3: compare s2, s3 with compareTo(), print out which string (s2 or s3)

// is

// greater than which string (s2 or s3), or equal, print the result out

if (s2.compareTo(s3) == 0)

System.out.println("They are equal");

else if (s2.compareTo(s3) > 0)

System.out.println("s2 is greater");

else

System.out.println("s3 is greater");

// To do 4: Use the regionMatches to compare s2 and s3 with case sensitivity of

// the first 8 characters.

// and print out the result (match or not) .

if (s2.substring(0, 8).compareTo(s3.substring(0, 8)) == 0)

System.out.println("They matched");

else

System.out.println("They DONT match");

// To do 5: Find the location of the first character 'g' in s1, print it out

int i;

for (i = 0; i < s2.length(); ++i)

if(s2.charAt(i)=='g')

break;

System.out.println("'g' is present at index " + i);

// To do 6: Find the last location of the substring "class" from s2, print it

// out

int index = 0, ans = 0;

String test = s2;

while (index != -1) {

ans = ans + index;

index = test.indexOf("class");

test = test.substring(index + 1, test.length());

}

System.out.println("Last location of class in s2 is: " + (ans + 1));

// To do 7: Extract a substring from index 4 up to, but not including 8 from

// s3, print it out

System.out.println(s3.substring(4, 8));

} // end main

} // end class StringLab9

7 0
3 years ago
The Next Einstein Initiative and the ________ Institute for Mathematical Sciences bring bright young learners and the best lectu
Degger [83]

Answer:

The correct answer is B. Africa

Explanation:

African Institute for Mathematical Sciences (AIMS) was founded in 2003 having its first center in Cape Town, South Africa. AIMS provides training for Africa's talented university graduates needed to enter technical professions or pursue graduate studies in technical fields. The Next Einstein Initiative (NEI) is a strategic plan to build on the success of the first AIMS centre and create a coordinated pan-African network of 15 AIMS centres by 2020, producing 750 well-qualified graduates per annum. AIMS won the Google's Project 10^100 and also the founder of AIMS won the TED Prize and announced his vision to unlock scientific talent across Africa.

5 0
3 years ago
Simpson is trying to solve an equation related to converting a decimal number to its hexadecimal form. He decides to utilize the
Marina86 [1]
Divide 1210 by 16  and write reminder divide until value zero 

first step divide 1210 by 16 =  10 
then 75 divide by 16 =  11
4 

we can write 4 B A 
in hexadecimal 

4 0
3 years ago
Other questions:
  • On what dates did the 2016 Olympics take place( list all)
    9·2 answers
  • In a chassis, the path along which air from a cool air source is conducted, past equipment to cool it, and then out of the rack.
    13·1 answer
  • If you want a user to actively participate in an online activity, create a web ______________.
    12·2 answers
  • ERP packages are always quite simple.<br><br> True<br><br> False
    5·1 answer
  • Which method is used for resolving data dependency conflict by the compiler itself?
    6·1 answer
  • What are the three uses of a screw?​
    13·2 answers
  • Which of the following is a particularly useful feature of Microsoft PowerPoint and
    8·2 answers
  • Jeroo Bob has just awoken from a long night's sleep and is hungry for some winsum flowers. He walks out of
    7·1 answer
  • Which of the following tells the computer hardware what to do? A Information B) Software Procedures D People
    12·2 answers
  • Complete the statement below with the correct term.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!