AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



C-Sharp-programming: Write a program to print sum of individual numbers in C-sharp

Ex: Input : 1234

Output : 10

Sum of middle number & Sum of diagonal numbers also in above example

C-Sharp x 3
programming x 169
Posted On : 2019-02-21 01:23:24.0
profile MOHAMMAD SALEEM BASHA - anyforum.in MOHAMMAD SALEEM BASHA
267150
up-rate
0
down-rate

Answers


using System;
public class SumExample
{
public static void Main(string[] args)
{
int n,sum=0,m;
Console.Write("Enter a number: ");
n= int.Parse(Console.ReadLine());
while(n>0)
{
m=n%10;
sum=sum+m;
n=n/10;
}
Console.Write("Sum is= "+sum);
}
}

Posted On : 2019-02-25 23:36:21
Satisfied : 0 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188223731
Reply This Thread
up-rate
0
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in