Computer Science, asked by bhattsarika13, 8 months ago

...... Input a 4 digit number , separate its digits and display its sum of digits, product of digits and average of digits.



help me give the full program!!​

Answers

Answered by Kaushikkalesh
1

inp = input()

a,b,c,d = [int(i) for i in inp]

sum = a+b+c+d

product = a*b*c*d

average = sum/4

print(f"The Sum of the digits is {sum}\nThe Product of the digits is {product}\nThe Average of the digits is {average}\n")

Note - The Code is in Python

Please Mark this as Brainliest

And Thank Me

Answered by anindyaadhikari13
1

Question:-

Write a program to input a 4 digit number and separate the digits and display the sum and product of the digits.

Program:-

In Java.

import java.util.*;

class Number

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter a 4 digit number: ");

int n=sc.nextInt();

int s=0,p=1;

for(;n!=0;n/=10)

{

int a=n%10;

s+=a;

p*=a;

}

System.out.println("Sum of the digits: "+s);

System.out.println("Product of the digits: "+p);

}

}

Similar questions