Table of Contents
Do you know what information the article is going to tell you ?. C# Program to Find Sum of All Digits of a Given Number We are going to see clearly about this.

C# Program to Find Sum of All Digits of a Given Number
using System;
namespace system
{
class sumofdigits
{
static void Main(String[] args)
{
int a=567, sum=0, b;
//condition to check if the number is not 0
while(a!=0)
{
b=a%10; //extract a digit
sum=sum+b; //adding the digits
a=a/10; //remained number
}
Console.WriteLine("The sum of the digits is: " +sum);
}
}
}
The sum of the digits is: 18
Final Words
C# Program to Find Sum of All Digits of a Given Number We hope you find the information you are looking for through this article and we hope all your doubts are resolved through this article.