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

What is difference between method and function in c#?

465


What Is An Interface Class?

554


What is data bind in c#?

509


What do you know about device context?

517


Explain the advantage of using system.text.stringbuilder over system.string?

463






What is polymorphism and its types in c#?

453


In which format you can pass the value in the sleep function?

538


What is the difference between throw and throw ex?

464


How do you escape in c#?

494


What is an xsd file?

498


Explain the use of Mutex in C#?

555


Does console.writeline() stop printing when it reaches a null character within a string?

513


Is array passed by reference in c#?

510


Why we use extension method in c#?

501


What is asynccallback c#?

516