using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n,sum=0,temp;
Console.Write("Enter the number");
n = int.Parse(Console.ReadLine());
while (n != 0)
{
temp = n % 10;
sum = sum + temp;
n = n / 10;
}
Console.Write("The sum of the digits is:"+sum);
Console.ReadKey();
}
}
}
/*Do leave a comment if you find this useful*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n,sum=0,temp;
Console.Write("Enter the number");
n = int.Parse(Console.ReadLine());
while (n != 0)
{
temp = n % 10;
sum = sum + temp;
n = n / 10;
}
Console.Write("The sum of the digits is:"+sum);
Console.ReadKey();
}
}
}
/*Do leave a comment if you find this useful*/
No comments:
Post a Comment