Computer Science, asked by saquiba1798, 1 year ago

write a java program to input a no. & print all the odd nos. till there sum. without using buffered reader

Answers

Answered by hiramani7080
0
import java. util*;
class Result
{
public static void main (String args[ ] )
{
Scanner obj= new Scanner(System. in);

int num,sum=0;

System.out. println("Enter a number");
num= obj. nextInt( );

while (num!=0)
{
num= num%10;

if(num%2==1)
{
sum=sum+ num;
}

num= num/10;
}

System.out.println(" Sum of all odd numbers in the inputted number"+sum);
}
}
Answered by kavitaantil05p9dpwg
0
import have util* ..........
Similar questions