C Online Compiler
Example: Sum of Digits of a Number in C Without loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Sum of Digits of a Number in C Without loop #include <stdio.h> int main() { int x, sum = 0; printf ("Enter the 3 digit's integer number::\n"); scanf ("%d", &x); printf ("The sum of %d digits is = ", x); sum = (x % 10) + ((x / 10) % 10) + (x / 100); printf ("%d\n", sum); return 0; }
987
Output
Clear
ADVERTISEMENTS