For example:
c = a + b;
(This calculates the sum of a + b, and assigns the result to variable c.)
If you repeatedly want to add something to an accumulated sum:
b = b + a;
or better:
b += a;
For example:
c = a + b;
(This calculates the sum of a + b, and assigns the result to variable c.)
If you repeatedly want to add something to an accumulated sum:
b = b + a;
or better:
b += a;
For example:
c = a + b;
(This calculates the sum of a + b, and assigns the result to variable c.)
If you repeatedly want to add something to an accumulated sum:
b = b + a;
or better:
b += a;
For example:
c = a + b;
(This calculates the sum of a + b, and assigns the result to variable c.)
If you repeatedly want to add something to an accumulated sum:
b = b + a;
or better:
b += a;
Write an. Algorthim. To. Find the. Sum. Of. First15 natural. Numbers
#include
int sum (int min, int max) {return (max-min+1)*(max+min)/2;}
sum = 0; for (int i = 12; i
public int findSum(int n1, int n2) { return n1 + n2; }
write an assembly language program to find sum of N numbers
Since there is an infinite set of prime numbers the answer would be infinity.
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 an. Algorthim. To. Find the. Sum. Of. First15 natural. Numbers
In Java:sum = 0;for (i = 2; i
for(int i = 1; i < 100; i+=2) { System.out.println(i); }
#include
matrix
int sum (int min, int max) {return (max-min+1)*(max+min)/2;}
sum = 0; for (int i = 12; i
#include<stdio.h> void main() { int num, sum=0, i; printf("Enter ten numbers: \n"); for(i=0;i<10;i++) { scanf("%d",&num); sum += num; } printf("\n The sum of the numbers is %d",sum); getchar(); }
public int findSum(int n1, int n2) { return n1 + n2; }