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

To create a localized application which namespaces are necessary?

0 Answers   Siebel,


What?s a delegate?

3 Answers  


Which is faster list or dictionary in c#?

0 Answers  


Describe the types of comments in c#?

0 Answers  


What is delegation in oops?

0 Answers  






What is the c# equivalent of c++ catch (...), Which was a catch-all statement for any possible exception?

0 Answers  


What is static and use of it?

0 Answers  


What is the difference between ref & out parameters?

2 Answers  


Can we have static indexer in c#?

0 Answers  


What's the difference between System.String and System..StringBuilder in C#?

0 Answers   PUCIT,


How do you escape a character?

0 Answers  


What is datatable in c#?

0 Answers  


Categories