1. Sum OF Given number c#.
2. Reverse a number c#.
3. Count 1 in given number c#.
string getnumber = "";int sum = 0;
Console.Write("Enter No :");
getnumber = Console.ReadLine();
int one = 0;
for (int i = 0; i < getnumber.Length; i++)
{
string s = getnumber[i].ToString();
if (s == "1")
{
one++;
}
sum = sum + Convert.ToInt32(s);
}
Console.WriteLine("Sum Of Digits Of No :"+sum);
Console.WriteLine("No of One :" + one);
Console.Write("Reverse No.");
for (int i = getnumber.Length - 1; i >= 0; i--)
{
Console.Write(getnumber[i]);
}
No comments:
Post a Comment