64.3k views
1 vote
A center symmetric number is a number that reads the same backward as forward. For example, each of the following five-digit integers is a center symmetric number: 34543, 22222, 16361 and 77177. Write a program that reads in a five-digit integer and determines whether it is a center symmetric number. The screen dialog should appear as follows:

Case Input (1)
Enter a five-digit integer: 34543
34543 is a center symmetric number.
Case Input (II)
Enter a five-digit integer: 14543
14543 is not a center symmetric number.
Hint:
Example gets digit 8 of an integer a = 12845 ;
int a = 12845 ;
int d = a / 100% * 10 ;

User Roy Lee
by
7.9k points

1 Answer

1 vote

Final answer:

To check if a five-digit number is center symmetric, we compare the first and last digits, and the second and second-to-last digits. If they match, the number is center symmetric; otherwise, it is not.

Step-by-step explanation:

To determine if a five-digit integer is center symmetric, we can compare each digit with its corresponding digit from the opposite end of the number. Here's a simple program in pseudocode to do that:

  1. Prompt the user to enter a five-digit integer.
  2. Store the integer in a variable, for example, number.
  3. Extract each digit of the number by dividing and getting the remainder (modulus).
  4. Compare the first digit with the fifth, and the second with the fourth.
  5. If all the compared digits are equal, then number is center symmetric. Otherwise, it is not.

For example, if the input is 34543, after extracting and comparing the digits, we find that this number is center symmetric. However, 14543 is not.

User MatthewG
by
8.5k points