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 public void in c#?
What is difference between class and abstract class in c#?
What is thread in c#?
What is the difference between package and interface?
Why do we need indexer in c#?
What is the difference between gettype and typeof in c#?
What is view state c#?
Explain circular reference in c#?
Can non-default constructors be used with single call sao?
What is a c# delegate?
If you define a user defined data type by using the struct keyword, is it a value type or reference type?
What are extensions in c#?
Explain what is the smallest unit of execution in .net?
What is a function c#?
What are access modifiers in c#?