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
Explain About CLS?
What is console used for?
What is difference between dll and exe in c#?
What is string literal in c#?
Can interface have virtual methods in c#?
How to Show Message box in Metro Style App?
What are the 4 pillars of any object oriented programming language?
What is the main method?
What is disco?
Is c sharp open source?
How do you create partial methods?
What is a console in c#?
What is expandoobject in c#?
What is the use of ienumerable in c#?
What is cshtml?