Computer Science, asked by 1khushbooclg2001, 7 months ago

Write a program to check a number whether it is handsome number or not using function. Example: 1124 = 1+1+2 = 4 , 123 = 1+2 = 3. It mean last digit = sum of all previous digits. Then it is called handsome number. ​

Answers

Answered by ShamweelXD
1

you have not defined which language has to be used for making this program

Answered by raginisrivastava8466
2

Answer:

import java.util.*;

class handsome

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int d,s=0,n,n1;

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

n=sc.nextInt();

for(n1=n/10;n1>=0;n1/=10)

{

d=n1%10;

s+=d;

}

if(s==n1%10)

System.out.println("It is a handsome number");

else

System.out.println("It is not a handsome number");

}

}

Similar questions