C Program - Sum of digits of given number till single digit - 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 till single digit.
#include<stdio.h> 
int main(void) 
{ 
    long num; 
    int dig,sum; 
    printf("Enter any number : "); 
    scanf("%ld",&num); 
    printf("%ld-> ",num); 
    do 
    { 
        sum = 0;  
        while(num!=0)  
        { 
            dig=num%10; 
            sum+=dig; 
            num/=10; 
        } 
        printf("%d-> ",sum); 
        num=sum; 
    }while(num/10!=0);     
    return 0; 
}
Output:
Enter any number : 586596
586596-> 39-> 12-> 3

Happy Learning 🙂

C Program – Armstrong numbers between given numbers
C Program – Print prime numbers between two numbers
C Program – Print the sum of digits of given number
Java program to find sum of digits
C Program – Given number is Even or Odd
C Program – Reverse of a number
C Program – Find GCD of two numbers
C Program to add elements of an array
C Program – Addition of two Matrices Example
C Program – Multiplication of two Matrices Example
C Program – Ways to Generate Fibonacci Series
C Program – Check a number is Palindrome or not
C Program – Find the factorial of given number
C Program – Find a number is prime or not
C Program – Find Largest and Smallest number in an Array

C Program – Armstrong numbers between given numbers
C Program – Print prime numbers between two numbers
C Program – Print the sum of digits of given number
Java program to find sum of digits
C Program – Given number is Even or Odd
C Program – Reverse of a number
C Program – Find GCD of two numbers
C Program to add elements of an array
C Program – Addition of two Matrices Example
C Program – Multiplication of two Matrices Example
C Program – Ways to Generate Fibonacci Series
C Program – Check a number is Palindrome or not
C Program – Find the factorial of given number
C Program – Find a number is prime or not
C Program – Find Largest and Smallest number in an Array
 


Δ
 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 + –