#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();
}
double[] numsToSum; // the numbers you want to find the sum of
double sum = 0.0;
for(int i = 0; i < numsToSum.length; ++i) {
sum += numsToSum[i];
}
To write a C++ program to display the student details using class and array of object.
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.
program SumAndDifference; var num1, num2, sum, difference: integer; begin write('Enter first number: '); read(num1); write('Enter second number: '); read(num2); sum := num1 + num2; difference := num1 - num2; if sum > difference then written('The sum is greater: ', sum) else written('The difference is greater: ', difference); end. This program will prompt the user to enter two numbers, calculate their sum and difference, and then compare the two values. If the sum is greater than the difference, it will display the sum; otherwise, it will display the difference.
class simple { public static void main(String[] args){System.out.println(new java.util.Scanner(System.in).nextDouble());} }
#include<iostream> int main (void) { int a, b; std::cout << "Enter two whole numbers:"; std::cin >> a >> b; std::cout << "The largest of " << a << " and " << b << " is << (a>b?a:b) << std::endl; }
The simplest way is probably to read the numbers into an array and then prints each element of the array starting at the last one and moving backwards.
$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"
1. write a 'c' program to read 4(four)numbers from a file 'BANK' and calculate the average of the numbers.Now print the calculated average in another output file 'AVERAGE' 2. write a 'c' program that finds the sum and average of inputted five integer numbers of the array using dynamic memory allocation function malloc(). 3. write a 'c' program to create simple elements 1,2,3,4 in the link list of 4(four)nodes and display the list's elements. 4. write a 'c' program to convert the expression (A+B)/(C+D) into postfix expression into stack.and then evaluate it for A=10,B=20,C=15,D=5 and display the stack status after each operation. 5. write a 'c' programto create a linked list implemented on an array containing the following numbers:1,2,3,3,3,4,4,9 and pack it to remove the duplicate numbers.so that only the following data are contained by the nodes:1,2,3,4,9
write a c++program by using if statement to read a number and check whether it is positive or negative
It separates the numbers
abdulrahman
the decimal point