City Suvidha...your one stop Search

Java Programs

Go Back to List

Program to find the sum of the digits of a  number .
 

class sumdigit
{
public static void main(String args[])
{
int r=0,num,n;
num=Integer.parseInt(args[0]);
System.out.print(“Number is”+num);
while(num>0)
{
n=num%10;
num=num/10;
r=r+n;
}
System.out.print(“\nNumber ”+r);
}
}
 

Output:

 

If any of you want to submit your programs and contribute to site please mail us at:

citysuvidha@gmail.com

Click here to have a look at  List of programs

You can download all the programs in a zip file also. For this you have to do one thing. Just register at the citysuvidha forum  and start any thread of any topic.  Once you start the thread and put your request, admin will automatically send you the desired zip file.