answersLogoWhite

0

import java.io.*;
class PerfectPalindrome
{
private boolean per(int a)
{
int b=0,c=1;
for(;c<=(a/2);c++)
{
if(a%c==0)
{
b+=c;
}
}
if(a==b)
return true;
else
return false;
}
private boolean pal(int a)
{
int b=a,c=0;
for(;b>0;b/=10)
{
int d=b%10;
c=(c*10)+d;
}
if(c==a)
return true;
else
return false;
}
public static void main()throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("1. Find a number is a perfect one or not !");
System.out.println("2. Find a number is a palindrome or not !");
System.out.print("\nEnter your Choice: ");
int a=Integer.parseInt(in.readLine()),c;
System.out.print("Enter the Number: ");
c=Integer.parseInt(in.readLine());
boolean b;
PerfectPalindrome e=new PerfectPalindrome();
switch(a)
{
case 1: b=e.per(c);
if(b==true)
System.out.print("It is a Perfect Number !");
else
System.out.print("It is not a Perfect Number !");
break;
case 2: b=e.pal(c);
if(b==true)
System.out.print("It is a Palindrome Number !");
else
System.out.print("It is not a Palindrome Number !");
break;
default: System.out.print("SORRY!! Wrong Choice!");

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Make a C programming that displays the first four perfect numbers?

create a program that iterates until it finds a perfect number, then store that perfect number into an array. Continue iterating until you find three more. Then, you have an array of four perfect numbers.


How do you write a C program to find out perfect numbers from 1 and 50?

To find perfect numbers between 1 and 50 in a C program, you can iterate through each number in that range and check if it is equal to the sum of its proper divisors. A perfect number is defined as a number that is equal to the sum of its positive divisors, excluding itself. Here's a basic outline of the program: #include &lt;stdio.h&gt; int main() { for (int num = 1; num &lt;= 50; num++) { int sum = 0; for (int i = 1; i &lt;= num / 2; i++) { if (num % i == 0) sum += i; } if (sum == num) printf(&quot;%d is a perfect number\n&quot;, num); } return 0; } This code checks each number from 1 to 50 and prints out the perfect numbers found in that range.


How do you write a C program to Print 1st 30 Perfect numbers starting from 0?

int i; for (i=2; i&lt;=30; i+=2) printf ("%d\n", i);


C program to check given number is a perfect square or not?

#include &lt;stdio.h&gt; #include &lt;math.h&gt; int main(void) { int number; double result; printf ("\n Introduce an integer: "); scanf ("%i", &amp;number); result= sqrt (number); if ((result * result)== number) printf ("\n The integer HAS a perfect square \n\n"); else printf ("\n The integer DOES NOT HAVE a perfect square \n\n"); getch (); } Shrikanth Ganure The Oxford College of Engineering (MCA-2010 Batch) Bangalore..


What is a flowchart for finding perfect no?

flow chart to find whther the given number is perfect or not

Related Questions

Write a c program using while loop to accept a number check and display message whether number is perfect or not?

The program is here guys.......... //Finding whether the given number is perfect or not //Starts here #include&lt;stdio.h&gt; void main() { int i=1,temp=0,number; scanf("%d",&amp;number); while(i&lt;=number/2){ if(number%i==0) temp+=i; i++; } if(temp==number) printf("Its a perfect number"); else printf("Its not a perfect number"); } //ends here


Make a C programming that displays the first four perfect numbers?

create a program that iterates until it finds a perfect number, then store that perfect number into an array. Continue iterating until you find three more. Then, you have an array of four perfect numbers.


Write a program number as a peimeter and checks whether it is perfect or not in java?

class perfect{public static void main(int n) // input as parameter{int a=0;for(int i=1;i


How do you write a C program to find out perfect numbers from 1 and 50?

To find perfect numbers between 1 and 50 in a C program, you can iterate through each number in that range and check if it is equal to the sum of its proper divisors. A perfect number is defined as a number that is equal to the sum of its positive divisors, excluding itself. Here's a basic outline of the program: #include &lt;stdio.h&gt; int main() { for (int num = 1; num &lt;= 50; num++) { int sum = 0; for (int i = 1; i &lt;= num / 2; i++) { if (num % i == 0) sum += i; } if (sum == num) printf(&quot;%d is a perfect number\n&quot;, num); } return 0; } This code checks each number from 1 to 50 and prints out the perfect numbers found in that range.


What is the sum of the first perfect number and the second perfect number?

The sum of the 1st perfect number and 2nd perfect number is. . . 34!


What is it called when a number has a whole number square root?

Then the number is called a "perfect square".Then the number is called a "perfect square".Then the number is called a "perfect square".Then the number is called a "perfect square".


Can a perfect number be odd?

If by 'perfect number' you mean 'perfect SQUARE', then yes. 49 is an odd number and a perfect square.


What is the third perfect number?

496 is the third perfect number and 8128 is the fourth perfect number.


What number is both a square number and a cube number between 1 and 25?

There is not a number that is a perfect square and perfect cube between 1 and 25.There is not a number that is a perfect square and perfect cube between 1 and 25.There is not a number that is a perfect square and perfect cube between 1 and 25.There is not a number that is a perfect square and perfect cube between 1 and 25.


Is 28 a perfect number?

Yes it is. 6 is the first perfect number, 28 is the second perfect number.


Is 77 a perfect number?

75 is not a Perfect number.


Is the number 32 a perfect number?

32 is not Perfect.