import java.io.*;
public class sum{
public static void main(String[] args) {
try{
System.out.print("Enter 10 numbers: ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int[] input=new int[10];
int a,total=0;
for(a=0;a<10;a++) {
System.out.println();
input[a]=Integer.parseInt(br.readLine());
}
for(a=0;a<10;a++) {
total+=input[a];
}
System.out.println("The sum of the numbers is "+total);
}catch(Exception e) {
e.printStackTrace();
}
}
}
to print the sum of first ten numbers:- void main() {int i,sum; sum=0; while(i<=10) sum=sum+i; i=i+1; } printf("The sum is : %d",sum); }
Sum = Sum + first number Sum = Sum + second number Sum = Sum + third number Average = 1/3 x Sum
In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT "Enter a number: "; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT "The sum of the digits is "; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.
#include<iostream> unsigned sum_of_digits(unsigned num) { unsigned sum = 0; do { sum += num%10; } while (num/=10); return sum; } int main() { unsigned number = 12345; unsigned sum = sum_of_digits (number); std::cout << "Sum of digits in " << number << " is " << sum << std::endl; }
you can use the condition statement like for(i=0:i<=10;i++)
ten ones with an infinite number of zeroes.
118
129 - 112 = 17
Five
312
I am an even three digit number If you round me to the nearest ten I become 200 The sum of my digets is 18 What number am I?
9+90=99 (90 is ten times as much as 9)
48
the product of 8 and the sum of 10 and -7
The number of 0s in the product is equal to the sum of the number of 0s in the whole number that you started with and the power [of ten].
Sum = 0 For N = 1 to 10 Sum = Sum + 2*N Next N Print Sum
Oh, isn't that just lovely? To express the sum of a number and ten in mathematical terms, you simply write it as "x + 10" where 'x' represents the number you're adding ten to. Just imagine that number and ten dancing together on the canvas of mathematics, creating a beautiful harmony of addition. Happy little numbers!