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

What is abstract class ?

5 Answers   Digital GlobalSoft,


What is sqldataadapter in c#?

0 Answers  


What is the difference between c and c sharp?

0 Answers  


For a combobox and a listbox same datatable given as a datasource. Now problem is that whenever focus of listbox changes selected value of combobox also get change or vice versa. what to be done to avoid this. According to requirement we cannot make different datasouce.

2 Answers   Syntel,


Can the accessibility of a type member be greater than the accessibility of its containing type?

0 Answers  






Difference between debug.write and trace.write?

0 Answers  


Can you mark static constructor with access modifiers?

0 Answers  


Did it possible to cast a generic type of derived class to generic type of base class?

2 Answers   TCS,


what is output parameter and parameter array?

1 Answers   TCS,


What is the benefit of dependency injection c#?

0 Answers  


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

0 Answers  


What is 8 bit signed integer?

0 Answers  


Categories