a certain program input ten numbers via keyboard and add up all the numbers less than zero

canadianvice

Distinguished
Jul 25, 2012
234
1
18,915
47
Are you looking for code?
(This is in python, but easy to adapt for other languages)
Python:
def sum_below_zero():
    total = 0
    temp_val = 0
    for i in range(10):
        temp_val = int(input("Input a number: "))
        if temp_val < 0:
            total += temp_val
     
    return total
 
Thread starter Similar threads Forum Replies Date
aymen9309 Apps General Discussion 1
SyndiShanX Apps General Discussion 3
D Apps General Discussion 1
BlueMoon1890 Apps General Discussion 0
Neon The (Anthro) Umbreon Apps General Discussion 1
K Apps General Discussion 2
T Apps General Discussion 10
Y Apps General Discussion 1
I Apps General Discussion 2
S Apps General Discussion 1
S Apps General Discussion 3
Rainfire Apps General Discussion 3
J Apps General Discussion 1
M Apps General Discussion 6
shiftyape Apps General Discussion 3
S Apps General Discussion 4
S Apps General Discussion 6
H Apps General Discussion 1
Samy0806 Apps General Discussion 4
S Apps General Discussion 3

ASK THE COMMUNITY