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
What is escape character in c#?
Is c# good for games?
What is parallel programming in c#?
Why is hashset faster?
Does google use c#?
How to declare a property in a class?
Can an abstract class have a constructor c#?
What is lazy t?
Explain the difference between Metadata and Manifest
What is base class in c#?
You are designing a user control. You created new property called backgroundimage which is of type image. You wanted to disable storing this property in the user’s form. How to achieve this?
What are namespaces, and how they are used?
What is difference between ienumerable and enumerable in c#?
Can an exception be thrown from a catch block?
What is dll in c#?