0% found this document useful (0 votes)
4 views5 pages

Computer HW 2

class notes

Uploaded by

htuthkhh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Computer HW 2

class notes

Uploaded by

htuthkhh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Q1 WAP to display abundant no or not

import java.util.*;
class cal
{
public static void main(int n)
{
int i,s=0;
for(i=1;i<n;i++)
if (n%i==0)
}
s=s+I;
{
if (s>n)
System.out.println(“abundant no)”;
else
System.out.pritln(“not a no”);
}
}
--------------------------------------------------------------------------------------------
----
Q2 WAP to input a 5 digit no and print the prime digits of the no.
--------------------------------------------------------------------------------------
Q3. Wap to input a no between 6 to 9 digits and display the absolute
difference between the sum of odd and even digits
import java.util.*;
class cal
{
public static void main()
{
Scanner sc=newScanner(System.in);
Sopln(“enter a no between 6 to 9 digits”);
n=sc.nextInt();
{
int r,oddsum=0,evensum=0,
while(n>0)
r=n%10;
if (r%2==0)
evensum+=r;
else
oddsum+=r;
n=n/10;
}
int differ=Math.abs(oddsum-evensum);
Sopln(differ);
}
}
--------------------------------------------------------------------------------------------
---------------------

Q4.
--------------------------------------------------------------------------------------------
-------------------
Q5. XYLEM NO
import java.util.*;
class cal
{
public static void main()
{
Scanner sc=new Scanner(System.in);
Sopln(“enter a no”);
n=sc.nextInt();
int id=n%10;
n=n/10;
int mean=0;
while(n>9)
{
int r=n%10;

You might also like