Page 455 - CA_Blue( J )_Class10
P. 455
23 boolean t=false;
24 System.out.print("Enter a number to check palindrome : ");
25 num=sc.nextInt();
26 t=palindrome(num);
27 if(t)
28 System.out.println(num+" is palindrome number");
29 else
30 System.out.println(num+" is not palindrome number");
31 }
32 }
Output
Enter a number to check palindrome : 141
141 is palindrome number
Enter a number to check palindrome : 140
140 is not palindrome number
Variable Description
NAME DATATYPE DESCRIPTION
n int Formal Parameter for number to check palindrome
rem int Remainder when divided by 10
rev int Stores reverse of the number
temp int Temporary variable to hold the quotient
num int Actual Parameter for number to check palindrome
t boolean Holds true if palindrome else false
(b) Program depicting the concept of impure method.
Program 2 Write a impure method to print the factorial of a number.
1 import java.util.*;
2 class factorial_method
3 {
4 void factorial(int n) // Impure Method
5 {
6 int i,f=1; // Declaration of variables
7 for(i=1;i<=n;i++) // Calculation of factorial
453
Internal Assessment 453

