Problem Description
Write a program to find the sum of negative numbers
Input:Positive and negative numbers
Output:Display Sum of negative numbers
Refer sample input and output for formatting specification.CODING ARENA
a=int(input())
sum=0
for i in range(a):
b=int(input())
if(b<0):
sum+=b
print("Sum of negative numbers:",sum)
Test Case 1
Input (stdin)7 10 -10 -43 -45 46 30 31
Expected OutputSum of negative numbers: -98
Test Case 2
Input (stdin)5 10 -10 -43 -45 -46
Expected OutputSum of negative numbers: -144
No comments:
Post a Comment