Computer Project Icse Class 10 Example (For Hint Purpose Only)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

SUBMITTED BY:-

SUBMITTED TO:-

NAME:-SAIYAM KAPUR MRS.ANU CHAUHAN

CLASS:-10TH B

ROLL NUMBER:-32

ADMISSION NUMBER:-7180
INDEX
SERIAL NUMBER TITLE DATE SIGNATURE

1. PRIME NUMBER 05-05-2021

2. COMPOSITE NUMBER 05-05-2021

3. PALINDROME NUMBER 05-05-2021

4. ARMSTRONG NUMBER 05-05-2021

5. AUTOMORPHIC NUMBER 05-05-2021

6. PRONIC NUMBER 05-05-2021

7. NIVEN NUMBER 05-05-2021

8. NEON NUMBER 05-05-2021

9. TWIN PRIME NUMBER 05-05-2021

10. DUCK NUMBER 05-05-2021

11. PERFECT NUMBER 05-05-2021

12. GCD OR HCF OF TWO NUMBERS 05-05-2021

13. FIND FACTORS OF ENTERED NUMBER 05-05-2021

14. FIND FACTORAL OF ENTERED NUMBER 05-05-2021

15. TECH NUMBER 05-05-2021

16. SPY NUMBER 05-05-2021

17. SUM OF DIGITS OF ENTERED NUMBER 05-05-2021

18. SPECIAL NUMBER 05-05-2021


Q.1 PRIME NUMBER

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS PRIME OR NOT

public class Prime

int num;

Prime(int a)

num=a;

public void check()

int i;

float prime;

for(i=2;i<=num;i++)

prime=num%i;

if(prime==0)

break;

if(num==i)

System.out.println("Prime Number");

else

System.out.println("Not a Prime Number");

OUTPUT:-

Prime Number
6

Not a Prime Number.

Q.2 COMPOSITE NUMBERS

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS COMPOSITE NUMBER OR NOT

import java.util.Scanner;

public class Composite_Number

public static void main(String args[])

int n,c=0,i;

Scanner sc=new Scanner(System.in);

System.out.println("Enter any Number");

n=sc.nextInt();

for(i=2;i<n;i++)

if(n%i==0)

c++;

if(c>=1)

System.out.println("Number is Composite Number");

else

System.out.println("Number is not a Composite Number");

OUTPUT:-

Enter any Number

5
Number is not a Composite Number

Q.3 PALINDROME NUMBER

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS PALINDROME OR NOT

import java.util.Scanner;

public class Palindrome_Number

public static void main(String args[])

System.out.println("Enter the Number");

Scanner sc=new Scanner(System.in);

int num=sc.nextInt();

int num1,mod;

mod=num%10;

num1=num/10;

if(num1==mod)

System.out.println("Number is Palindrome");

else

System.out.println("Number is not Palindrome");

OUTPUT:-

Enter the Number

Number is not Palindrome

Q.4 ARMSTRONG NUMBER


SOURCE CODE:-

import java.util.Scanner;

public class Armstrong_Number

public static void main(String args[])

int number=153;

int check,rem,sum=0;

System.out.println("Enter the Number");

Scanner sc=new Scanner(System.in);

number=sc.nextInt();

check=number;

while(check!=0)

rem=check%10;

sum=sum + (rem*rem*rem);

check=check/10;

if(sum==number)

System.out.println("It is an Armstrong Number");

else

System.out.println("It is not an Armstrong Number");

OUTPUT:-

Enter the Number

It is not an Armstrong Number

Q.5 AUTOMORPHIC NUMBER


SOURCE CODE:-

import java.util.Scanner;

public class Automorphic

public static void main(String args[])

Scanner in = new Scanner(System.in);

System.out.println("Enter a Number");

int num = in.nextInt();

int c=0, sqr = num*num;

int temp =num;

while(temp>0)

c++;

temp=temp/10;

int lastSquareDigits = (int) (sqr%(Math.pow(10,c)));

if(num == lastSquareDigits)

System.out.println("Automorphic Number");

else

System.out.println("Not an Automorphic Number");

OUTPUT:-

Enter a Number

Not an Automorphic Number

Q.6 PRONIC NUMBER


SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS PRONIC OR NOT

import java.util.Scanner;

public class Pronic_Number

public static void main(String args[])

Scanner sc = new Scanner(System.in);

System.out.println("Input a Number : ");

int num = sc.nextInt();

int ans = 0;

for(int i=0; i<num; i++)

if(i*(i+1) == num)

ans = 1;

break;

if(ans == 1)

System.out.println("Pronic Number");

else

System.out.println("Not a Pronic Number");

OUTPUT:-

Input a Number :

10

Not a Pronic Number


Q.7 NIVEN NUMBER

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS NIVEN OR NOT

import java.util.Scanner;

public class Niven_Number

public static void main(String args[])

Scanner sc=new Scanner(System.in);

System.out.println("Enter the Number");

int n=sc.nextInt();

int Sum=0,z=n;

int d=z/10;

while (z>0)

Sum +=d;

z=z/10;

if (n/Sum==0)

System.out.println("It is not a Niven Number");

else

System.out.println("It is a Niven Number");

OUTPUT:-

Enter the Number

11

It is a Niven Number
Q.8 NEON NUMBER

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS NEON OR NOT

import java.util.Scanner;

public class Neon_Number

public static void main(String args[])

int sum = 0,n;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the Number");

n =sc.nextInt();

int square = n * n;

while(square != 0)

int digit = square%10;

sum = sum+digit;

square = square/10;

if(n == sum)

System.out.println(n +" is a Neon Number");

else

System.out.println(n +" is not a Neon Number");

OUTPUT:-

Enter the Number

12
12 is not a Neon Number

Q.9 TWIN PRIME NUMBERS

SOURCE CODE:-

//PROGRAM TO CHECK WHETHER A NUMBER IS TWIN PRIME OR NOT

import java.util.Scanner;

public class Twin_Prime_Number

public static void main (String args[])

Scanner in = new Scanner(System.in);

System.out.println("Enter First Number:");

int a = in.nextInt();

System.out.println("Enter Second Number:");

int b = in.nextInt();

boolean isAPrime = true;

for (int i = 2; i <= a / 2; i++)

if (a % i == 0)

isAPrime = false;

break;

if (isAPrime && Math.abs(a - b) == 2)

boolean isBPrime = true;

for (int i = 2; i <= b / 2; i++)

{
if (b % i == 0)

isBPrime = false;

break;

if (isBPrime)

System.out.println(a + " and " + b + " are twin prime");

else

System.out.println(a + " and " + b + " are not twin prime");

else

System.out.println(a + " and " + b + " are not twin prime");

OUTPUT:-

Enter First Number:

22

Enter Second Number:

23

22 and 23 are not twin prime

Q.10 DUCK NUMBER

SOURCE CODE:-

//PROGRAM TO CHECK WHETHER A NUMBER IS DUCK NUMBER OR NOT

import java.util.Scanner;

public class Duck_Number


{

public static void main(String args[])

Scanner sc=new Scanner(System.in);

System.out.println("Enter a Number");

int num=sc.nextInt();

int c = 0;

int r;

while(num!=0)

r=num%10;

if(r==0)

c++;

num=num/10;

if(c>0)

System.out.println("It is a Duck Number");

else

System.out.println("It is not a Duck Number");

OUTPUT:-

Enter a Number

15

It is not a Duck Number

Q.11 PERFECT NUMBER

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS PERFECT NUMBER OR NOT


import java.util.Scanner;

public class Perfect_Number

public static void main(String args[])

long n,sum=0;

Scanner sc=new Scanner(System.in);

System.out.println("Enter a Number");

n=sc.nextLong();

int i=1;

while(i<=n/2)

if(n%i==0)

sum+=i;

i++;

if(sum==n)

System.out.println(n+" is a Perfect Number");

else

System.out.println(n+" is not a Perfect Number");

OUTPUT:-

Enter a Number

16

16 is not a Perfect Number


Q.12 GCD OR HCF OF TWO NUMBERS

SOURCE CODE:-

//PROGRAM TO FIND GCD OR HCF OF TWO NUMBERS

import java.util.Scanner;

public class GCD_or_HCF_of_Two_Numbers

public static void main(String args[])

Scanner sc=new Scanner(System.in);

int num1,num2,mod=0;

System.out.println("Enter Number 1");

num1=sc.nextInt();

System.out.println("Enter Number 2");

num2=sc.nextInt();

while(num1%num2!=0)

mod=num1%num2;

num1=num2;

num2=mod;

System.out.println("GCD of Two Numbers =" +num2);

OUTPUT:-

Enter Number 1

17

Enter Number 2

18

GCD of Two Numbers =1


Q.13 FIND FACTORS OF ENTERED NUMBERS

SOURCE CODE:-

//PROGRAM TO FIND FACTORS OF A NUMBER

import java.util.Scanner;

public class Factors

public static void main(String args[])

Scanner sc=new Scanner(System.in);

int num,i;

System.out.println("Enter a Number");

num=sc.nextInt();

for(i=1;i<=num;i++)

if(num%i==0)

System.out.println(i+"");

OUTPUT:-

Enter a Number

18

18
Q.14 FIND FACTORAL OF ENTERED NUMBER

SOURCE CODE:-

//PROGRAM TO FIND FACTORIAL OF A NUMBER

public class Factorial

public static void main(String args[])

int i,n,fact;

n=5;

fact=1;

for(i=1;i<=n;i++)

fact=fact*i;

System.out.println("The Factorial of " + n + " is "+ fact);

OUTPUT:-

The Factorial of 5 is 120

Q.15 TECH NUMBER

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS TECH NUMBER OR NOT

import java.util.Scanner;

public class Tech_Number

{
public static void main(String args[])

Scanner sc = new Scanner( System.in );

System.out.println("Enter the number");

int n=sc.nextInt();

int c=0;

while(n>0)

c++;

n=n/10;

if(c%2==0)

System.out.println("Tech number");

else

System.out.print("Not a tech number");

OUTPUT:-

Enter the number

20

Tech number

Q.16 SPY NUMBER

SOURCE CODE:-

//PROGRAM TO FIND WHETHER A NUMBER IS SPY OR NOT

import java.util.Scanner;

public class Spy_Number

public static void main(String args[])


{

int num, product=1, sum=0, lastdigit;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the Number");

num=sc.nextInt();

while(num>0)

lastdigit=num%10;

sum=sum+lastdigit;

product=product*lastdigit;

num=num/10;

if(sum==product)

System.out.println("The Given Number is a Spy Number");

else

System.out.println("The Given Number is not a Spy Number");

OUTPUT:-

Enter the Number

22

The Given Number is a Spy Number

Q.17 SUM OF DIGITS OF ENTERED NUMBER

SOURCE CODE:-

//TO FIND SUM OF DIGITS OF THE ENTERED NUMBER

import java.util.Scanner;

public class Digits_Sum

{
public static void main(String args[])

int m, n, sum = 0;

Scanner s = new Scanner(System.in);

System.out.println("Enter the number");

m = s.nextInt();

while(m > 0)

n = m % 10;

sum = sum + n;

m = m / 10;

System.out.println("Sum of Digits:"+sum);

OUTPUT:-

Enter the number

24

Sum of Digits:6

Q.18 SPECIAL NUMBER

SOURCE CODE:-

//TO CHECK WHETHER THE NUMBER IS SPECIAL OR NOT

import java.io.*;

public class Special_Number

public static void main(String args[]) throws IOException

InputStreamReader isr=new InputStreamReader(System.in);


BufferedReader br=new BufferedReader(isr);

System.out.println("Enter Number ");

int num=Integer.parseInt(br.readLine());

int num1,fact=1,sum=0,i=0;

int copy_num=num;

while(num>0)

num1=(num%10);

fact=1;

for(i=num1;i>=1;i--)

fact=fact*i;

sum=sum+fact;

num=num/10;

if(sum==copy_num)

System.out.println("**************************************************");

System.out.println("Actual Number= " + copy_num );

System.out.println("Factorisation of the Number=" + sum );

System.out.println("Thus," +copy_num + "is a Special Number");

System.out.println("**************************************************");

else

System.out.println("**************************************************");

System.out.println(copy_num + " is not a Special Number");

System.out.println("**************************************************");

OUTPUT:-

Enter Number

26
**************************************************

26 is not a Special Number

**************************************************

You might also like