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 difference between method and function in c#?
What Is An Interface Class?
What is data bind in c#?
What do you know about device context?
Explain the advantage of using system.text.stringbuilder over system.string?
What is polymorphism and its types in c#?
In which format you can pass the value in the sleep function?
What is the difference between throw and throw ex?
How do you escape in c#?
What is an xsd file?
Explain the use of Mutex in C#?
Does console.writeline() stop printing when it reaches a null character within a string?
Is array passed by reference in c#?
Why we use extension method in c#?
What is asynccallback c#?