answersLogoWhite

0


Best Answer

This is a very simple problem, alnost certainly a homework problem, and you should make an effort to answer it yourself.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a java program for sum of n numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a java program to find sum of even and odd numbers in given array?

for(int i = 1; i < 100; i+=2) { System.out.println(i); }


Java program to find sum on even numbers from 12-45?

sum = 0; for (int i = 12; i


How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.


How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


Write java program for mean of ten numbers?

// numbers to work with double[] nums = {1, 2, 3, 4.5, 5.5, 6, 7.5, 8, 9, 10}; double sum = 0; // total sum for (int i = 0; i < nums.length; ++i) { sum += nums[i]; } // final average final double mean = (sum / nums.length);


Write a C Program to print sum of squares of odd numbers?

#include


How do you write a program in java to print sum of first ten integers?

public class sum { public static void main(String args[]){ int sum=0; for(int i=1;i<=10;i++){ sum=sum+i; } System.out.println(sum); } }


How do you find sum of 100 numbers using fortran programme?

The following is for F95 and later (due to the use of intrinsic SUM ): My assumptions: -Your numbers are integers -Your numbers are stored in an array -The numbers you are describing are 0-100 program findSum !I assumed integer, replace this with your data type integer, dimension(100) :: numbers integer :: sumOfNumbers !We populate an array with our numbers !Replace this with your numbers do i=1,(size(numbers)+1) numbers = i end do !We find the sum of those numbers sumOfNumbers = sum(numbers) !We write out the sum to prompt write(*,*) 'Sum is: ', sumOfNumbers end program findSum


Write a program in c plus plus for finding the sum of first 10 even numbers?

int i, sum = 0; for (i=0; i<20; i+=2) sum+=i;


Write a C program to find the sum of all prime numbers?

Since there is an infinite set of prime numbers the answer would be infinity.


Write a java program that accepts 10 numbers and displays sum?

import java.util.Scanner; public class Sum { public static void main(String args[]) { int sum=0; Scanner s=new Scanner(System.in); for(int i=0;i<10;i++) { System.out.printf("enter a number:"); sum+=s.nextInt(); }//end of for }//end of main }//end of class


Write a program to calculate the sum of two numbers in unix?

$vi sum.sh echo "enter the 1st no." read num1 echo "enter the 2nd no." read num2 sum= 'expr $num1 + $num2' echo "sum of the numbers is $sum"