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
How to achieve polymorphism in c#?
Can constructor be overloaded in c#?
Why do we need singleton class in c#?
What is the purpose of reserved word using in c#?
Is namespace necessary in c#?
What is overloading with example?
What do you mean by serialization in .NET?
Do extension methods have to be static?
What is anonymous method in c#?
What is the default value of date?
What is the difference between ienumerable and icollection?
How do you serialize in c#?
What is difference between asp net and c# net?
What is Custom attribute? How to create? If I'm having custom attribute in an assembly, how to say that name in the code?
What is difference between static and readonly in c#?