Computer Science, asked by tripathiarchita36, 10 months ago

Q11. Write a program to input a number. Print sum and
average
of odd digits
of number
[12]​

Answers

Answered by Rahul9048
2

import java.until.Scanner;

public class AverageNumber {

public static void main( String [] args ) {

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int averageNumber = 0;

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

if( i % 2 != 0 ) {

averageNumber += i;

}

}

System.out.println(averageNumber);

}

}

Similar questions