Trending ▼   ResFinder  

ICSE − Q & A

ICSE
Indian Certificate of Secondary Education (ICSE), New Delhi
+Fave Message

Ask a Question

Answer a Question!

ResFinder - Thousands of Practice Papers

hi guys these are two answers to the disarmium question everyone has been bothered about- without using string functions
import java.util.Scanner;
public class disarmy1
{
    void hello()
    {  Scanner in = new Scanner(System.in);
        System.out.println("enter the number ahole");
        int s = in.nextInt();
        int a = s;
        int b=s;
        int d=0;//to find the digits
        int c=0;//to count the number of digits
        int i,e=0,sum=0;
        while(s>0)
        {  d= s%10;
            c++;
            s=s/10;
        }
        for(i=c;i>=1;i--)
        { 
            
            
          e= a%10;
           sum = sum+ (int)(Math.pow(e,i));//since i is equal to number of digits
            a=a/10;
        
       }
       if(sum==b)
       System.out.println("disarmium number");
       else
       System.out.println("not");
    }
}
//THIS IS THE SECOND ANSWER TO THE QUESTION WHICH IS A LITTLE HARDER TO COPREHEND 
import java.util.Scanner;
public class disarmy2
{
    void hello()
    {
        //this is using arrays
         Scanner in = new Scanner(System.in);
        System.out.println("enter the number ahole");
        int s = in.nextInt();
        int n =s;
        int q=s;
        int d=0;
        int i;
        int c=0;
        int x=0;
        int sum=0;
        while(s>0)//to find the number of digits the number has
        {d = s%10;
            c++;
            s=s/10;
        }
        int a[]= new int[c];
        for(i=0;i<c;i++)//to put all these digits into an array
        {
            x=n%10;
            a[i]= x;
            n=n/10;
        }
        for(i=c-1;i>=1;i--)//taking array from the last element and adding the power of index+1 of that number to sum
        {
            sum = sum+ (int)Math.pow(a[i],i+1);
        }
        if(sum==q)
        System.out.println("disarmium");
        else
        System.out.println(" not");
    }
    
}
asked by Sankhya Gowda (taankkkkk) 7 years ago
2

Other Questions on This Topic

Chhod aaye the kinara kabhi apni talash mein,
Par dil ki gehrayi se ek aisi aawaz aayi,
Ki lautna pada hamein isi mod ki talash mein.
asked by Nisarg Bhavsar (nisarg71) 26 days ago
2
Bengali grammar icse question paper can I get?
asked by Debosmita Malik (debosmitamalik) 80 days ago
1

+ 1 more questions by debosmitamalik  

I wish to download question papers for ICSE prelims and I cannot do that. Can you provide the details of the Customer support for Respaper to get in touch with regarding the issue mentioned above.
asked by S.Hemalata Rajaram (hema1877) 184 days ago
1

+ 2 more questions by hema1877  

unable to pay
can u send link
asked by Priya Mahendran (nana1804) 196 days ago
1

+ 1 more questions by nana1804  

When is the 2026 ICSE exam?
asked by Yogesh (yogesh) 243 days ago
1
https://www.respaper.com/
asked by Sujata Kundu (mumpi_1989) 1 year ago
0

+ 3 more questions by mumpi_1989  

i'm unable to download papers
asked by Tsa (rajpurohit14) 1 year ago
1
Class 9 final question paper
asked by Armaan Mandal (arms10) 1 year ago
0
How to contact respaper
asked by Insha Naz Fatima (sarahmeh) 1 year ago
1

Next Page >>

ICSE chat
© 2010 - 2026 ResPaper. Terms of ServiceContact Us Advertise with us