C# Program using Functions and loops - we should be concerned about the technology that continues to grow, because the technology is created to facilitate our lives, with technology we can do any job faster so save time and money, ok on the blog
Techno News Latest we will discuss a variety of new technologies that continue to grow, now we will membahs first about C# Program using Functions and loops please see to finish:
Articles :
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);
}
}
information C# Program using Functions and loops has been discussed
hopefully the information we have provided with the title C# Program using Functions and loops can provide more knowledge for you in determining the choice of gadget that suits your needs.
you just finished reading the article C# Program using Functions and loops if you think this information is worth to book mark or share please use link https://puriagatsari.blogspot.com/2013/12/c-program-using-functions-and-loops.html to get more information about gadget please visit other pages on this blog, thank you.
Tag :
Csharp,
programs,
0 komentar:
Posting Komentar