all about smartphone technologies we discuss here, ranging from specifications and prices, how to fix hp and we provide a lot of applications and games

C# Program using Functions and loops

C# Program using Functions and loops - welcome to our blog that presents a very complete information is Tech Phone ok now we will discuss the information you are seeking, may I guess if you are looking for information on C# Program using Functions and loops if properly come please continue reading until the end, we also provide other information, do not forget to get around:

informations : C# Program using Functions and loops
Full link : C# Program using Functions and loops
Article Csharp, Article programs,

You can also see our article on:


C# Program using Functions and loops

C# Program using Functions

Program Statement:
Write a function which takes one value as parameter and display the sum of digits in the value. e.g. if user has passed 125 then function will print 1+2+5 = 7

Solution:
 class _sum
{
long n, i, sum = 0;
public void add(long n)
{
for (i = n; i != 0; i = i / 10)
{
sum = sum + i % 10;

}
Console.WriteLine("\n\t\tSum of digits is : {0}", sum);
}
public void input()
{
Console.Write("\n\t\tEnter desired digit : ");
n = Convert.ToInt64(System.Console.ReadLine());
add(n);
}

}




Articles C# Program using Functions and loops already been discussed

A few information about the C# Program using Functions and loops, hopefully can provide benefits to all of you.

You're reading an article C# Program using Functions and loops and this article has a link to https://mastispotgroup.blogspot.com/2013/12/c-program-using-functions-and-loops.html to revel book mark. Hopefully this article could be useful, do not forget to look for information on obtaining the phone tech blog.

Tag : , ,
Share on Facebook
Share on Twitter
Share on Google+
Tags :

Related : C# Program using Functions and loops

0 komentar:

Posting Komentar