Question bank › Math
Dsa Math Medium

Digit Sums and Products

You need to write a program that calculates the sum and the product of the digits of an integer. Your program should handle both positive and negative integers. If the integer is negative, consider only the digits and ignore the sign. Input Format: - A single integer, which can be negative or positive. Output Format: - Print two integers: the sum of the digits and the product of the digits, separated by a space. Example: Input: -123 Output: 6 6 (The sum is 1 + 2 + 3 = 6; the product is 1 * 2 * 3 = 6)

Key concepts

mathdigit_manipulationloops

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.