Skip to main content

Posts

Showing posts with the label iteration

PYRAMID SHAPE: USING FUNCTION CALLING

PYRAMID SHAPE: USING FUNCTION CALLING ANOTHER FUNCTION AIM:   TO PRINT THE PYRAMIDAL SHAPE USING LOOP CONCEPT AND PRINTING NUMBERS EXAMPLE:                 1              2 3            4 5 6           7 8 9 10 SYNTAX import java.io.*; class pattern2 {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         System.out.println("Enter No. of lines to print");         int n= Integer.parseInt(br.readLine());         int x=1;         int l=n-1;         for(int i=1;i<=n;i++)         { spaces(l--);             for(int j=1;...

Disarium Number

AJ Java Programs Program 4: Disarium Number A number will be called DISARIUM if sum of its digits powered with their respective position is equal to the original number. For example  135 is a DISARIUM (Workings 1 1 +3 2 +5 3  = 135, some other  DISARIUM  are 89, 175, 518 etc) Syntax: import java.io.*; class disarium {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         int n,n1,n2,c=0,sum=0,d=0;         System.out.println("Enter a Num");         n=Integer.parseInt(br.readLine());         n2=n1=n;         while(n2!=0)         {             n2=n2/10;             c++;         }       ...

Automorphic Number

AJ Java Programs Program 3 : Automorphic Number     A Number is said to be Automorphic if its square contains digits same as number. For Example:-  25 is Automorphic Number Since its Square 625 contains the original number 25. Syntax import java.io.*; class automorphic {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         int n,sq,c=1,d=0;         System.out.println("Enter a Number");         n=Integer.parseInt(br.readLine());         sq=n*n;         int n1=n;         while(n!=0)         {             d=n%10;             c=c*10;             n=n/10;         ...