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?



I want to single value if you give any integer value. Below are examples  1. Input: 123  Ou..

Answer / 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

More C Sharp Interview Questions

One start and stop button is there and one textbox is there.when you click start button ,it will display 1,2,3......up to infinite in textbox.when you click stop button it will stop.

1 Answers  


What are the methods in c#?

0 Answers  


When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?

2 Answers   Mind Tree,


Is list ienumerable c#?

0 Answers  


What is icomparer in c#?

0 Answers  






What is the data provider name to connect to access database?

0 Answers  


What is an ienumerable in c#?

0 Answers  


What is a byte in c#?

0 Answers  


What is difference between value and reference types?

5 Answers   Accenture,


Explain the use of virtual, sealed, override, and abstract method?

0 Answers  


What is serializable in c#?

0 Answers  


What is constructors, explain with syntax

0 Answers  


Categories