-
A simple java program sum of n number
Hey guy i am in big problem.Actually i don't having much knowledge about Java.I am familiar only with Java.I don't have much knowledge about programing.So guys help me in writing a program on to above topic "A simple Java programing sum of n number using class,object and methods."
-
Re: A simple java program sum of n number
i hope this will help u
****** Java Program To Print Sum Of 'n' Number ******/
class Add
{
public static void main (String args[])
{
int n = 15;
int sum = 0;
for(int i = n;i>=0;i--)
sum = sum + i;
System.out.println("Sum = "+ sum);
}
}
/*************** OUTPUT *************
* *
* Sum = 120 */
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks