Info C# Program using Functions and loops - this blog we have built from a few years ago and already very much information about gadgets that we convey and a lot of blog visitors
New Blog Techno News who are satisfied with the information, we will always try to update the latest information for you, first about Info C# Program using Functions and loops many already we collect data to make this article so you do not miss the news, please see:
Articles :
Info C# Program using Functions and loops
full Link :
Info C# Program using Functions and loops
Article Csharp,
Article programs,
You can also see our article on:
Info 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 Info C# Program using Functions and loops finished in discussion
hopefully the information we convey about Info C# Program using Functions and loops can benefit you in getting new knowledge about technology,
you just finished reading the information Info C# Program using Functions and loops we hope this informmation can answer the question you submit to googlle, if you want to bookmark or share please use link https://moymoycikukecik.blogspot.com/2013/12/info-c-program-using-functions-and-loops.html and do not forget to always visit this blog to get the latest information every day.
Tag :
Csharp,
programs,
0 komentar:
Posting Komentar