C Program - Print the sum of digits of given number - onlinetutorialspoint

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
C Program to print the sum of digits of a given number.
#include<stdio.h> 
int main(void) 
{ 
    int n,sum=0,rem; 
    printf("Enter a number to Calculate Sum: "); 
    scanf("%d",&n); 
    while(n>0) 
    { 
        rem = n%10;     
        sum+=rem; 
        n/=10;         
    } 
    printf("Sum of Digits=%d\n",sum); 
    return 0; 
}
Output:
Enter a number to Calculate Sum: 56489
Sum of Digits=32
Happy Learning 🙂
 

C Program – Armstrong numbers between given numbers
C Program – Reverse the Elements of an Array
C Program – Check a number is Palindrome or not
Python How to read input from keyboard
C Program – Sum of digits of given number till single digit
C Program – Print prime numbers between two numbers
Java program to find sum of digits
Java Program to Print Pattern Triangle
Java Program to Print Diamond Pattern
C Program – Bubble Sort Program in C
PHP Echo Vs Print Example Tutorials
Python – Print different vowels present in a String
C Program – Given number is Even or Odd
C Program – Reverse of a number
C Program – Find GCD of two numbers

C Program – Armstrong numbers between given numbers
C Program – Reverse the Elements of an Array
C Program – Check a number is Palindrome or not
Python How to read input from keyboard
C Program – Sum of digits of given number till single digit
C Program – Print prime numbers between two numbers
Java program to find sum of digits
Java Program to Print Pattern Triangle
Java Program to Print Diamond Pattern
C Program – Bubble Sort Program in C
PHP Echo Vs Print Example Tutorials
Python – Print different vowels present in a String
C Program – Given number is Even or Odd
C Program – Reverse of a number
C Program – Find GCD of two numbers
 


Δ
 C – Introduction
 C – Features
 C – Variables & Keywords
 C – Program Structure
 C – Comment Lines  & Tokens
 C – Number System
 C – Local and Global Variables
 C – Scope & Lifetime of Variables
 C – Data Types
 C – Integer Data Types
 C – Floating Data Types
 C – Derived, Defined Data Types
 C – Type Conversions
 C – Arithmetic Operators
 C – Bitwise Operators
 C – Logical Operators
 C –  Comma and sizeof Operators
 C – Operator Precedence and Associativity
 C – Relational Operators
 C Flow Control – if, if-else, nested if-else, if-else-if
 C – Switch Case
 C Iterative – for, while, dowhile loops
 C Unconditional – break, continue, goto statements
 C – Expressions and Statements
 C – Header Files & Preprocessor Directives
 C – One Dimensional Arrays
 C – Multi Dimensional Arrays
 C – Pointers Basics
 C – Pointers with Arrays
 C – Functions
 C – How to Pass Arrays to Functions
 C – Categories of Functions
 C – User defined Functions
 C – Formal and Actual Arguments
 C – Recursion functions
 C – Structures Part -1
 C – Structures Part -2
 C – Unions
 C – File Handling
 C – File Operations
 C – Dynamic Memory Allocation
 C Program – Fibonacci Series
 C Program – Prime or Not
 C Program – Factorial of Number
 C Program – Even or Odd
 C Program – Sum of digits till Single Digit
 C Program – Sum of digits
 C Program – Reverse of a number
 C Program – Armstrong Numbers
 C Program – Print prime Numbers
 C Program – GCD of two Numbers
 C Program – Number Palindrome or Not
 C Program – Find Largest and Smallest number in an Array
 C Program – Add elements of an Array
 C Program – Addition of Matrices
 C Program – Multiplication of Matrices
 C Program – Reverse of an Array
 C Program – Bubble Sort
 C Program – Add and Sub without using + –