C Program for Addition of Individual Digits of a Number

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Program for addition of individual digit of a number
#include<stdio.h>
#include<conio.h>
int main()
{
     int n,r,s=0;
     printf("\nEnter a number");
     scanf("%d",&n);
     while(n!=0)
     {
        r=n%10;
        s=s+r;
        n=n/10;
     }
    printf("Sum is %d ",s);
}

 

Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *