Sure! Here's a simple Python program that allows the user to input 5 numbers and then calculates and prints their total:
numbers = []
for i in range(5):
num = int(input("Enter a number: "))
numbers.append(num)
total = sum(numbers)
print("The total is:", total)
This program prompts the user to enter a number 5 times, converts each input to an integer, stores them in a list, calculates the sum of the numbers using the sum()
function, and finally prints the total.
#include
using std::cin;
using std::cout;
using std::endl;
int main()
{
int arrSize = 5;
double arr[arrSize] = {0.0};
cout << endl << "Enter 5 numbers to find its total." << endl;
for (int i = 0; i < arrSize; i++)
{
cout << "Enter " << (i + 1) << " element: ";
cin >> arr[i];
}
double sum = 0.0;
for (int i = 0; i < arrSize; i++)
{
sum += arr[i];
}
cout << endl << "Total is: " << sum << endl;
system("PAUSE");
return 0;
}
write a lex program to delete space from the program
How to write a program for mouse in microprocessor?
To write a C++ program to display the student details using class and array of object.
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
how to write a program that counts automorphic number from 1 to 999
Use the keyboard.
write a lex program to delete space from the program
write an assembly language program to find sum of N numbers
write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html
fdsgfhgdfhgdf
How to write a program for mouse in microprocessor?