I want to single value if you give any integer value. Below are examples 
1. Input: 123  Output: 6
2. Input: 99   9+9=18   1+8  Output: 9
How to get above output?

Answer Posted / vamshireddy

console.writeline("enter ur number");
int i=int.parse(console.readline);
int add=0;
int rem=0;
while(i!=0);
{
rem=i%10;
add=add+rem;
i=i/10;
}
console.writeline("result is"+add);
console.readline();

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to achieve polymorphism in c#?

542


Can constructor be overloaded in c#?

472


Why do we need singleton class in c#?

533


What is the purpose of reserved word using in c#?

499


Is namespace necessary in c#?

489






What is overloading with example?

493


What do you mean by serialization in .NET?

552


Do extension methods have to be static?

539


What is anonymous method in c#?

460


What is the default value of date?

450


What is the difference between ienumerable and icollection?

468


How do you serialize in c#?

468


What is difference between asp net and c# net?

479


What is Custom attribute? How to create? If I'm having custom attribute in an assembly, how to say that name in the code?

508


What is difference between static and readonly in c#?

444