Computer Science, asked by aditichowdhary15, 2 months ago

class abc
{
void fun(int a)
{
int sum = 0;
while(a>0)
{
int rem = a%10;
int sum = sum + rem;
int a = a/10;
}
System.out.println("sum of digit is : " +sum);
System.out.println("end");
}
}
please tell me the answer
no spam
the me what is wrong in this program and give me rhe output

Answers

Answered by kanishknautiyal
0

Explanation:

whole program is wrong

if you want to print a program and enters value from user the program will be for sum is

import java.util.scanner;

class Sum;

{

public static void main(String[] args)

{

Scanner scr = new Scanner(System.in);

System.out.println("enter first number");

int a = scr.nextInt();

System.out.println("enter second number");

int b = scr.nextInt();

int sum = Math.sum(a,b);

System.out.println("sum of two numbers is-"+sum);

}

}

any doubt direct me in Instagram @kanishk.nautiyal

Similar questions