+ 1

Find -ve and +ve value and sum in c

Execute the algorithm for 20 numbers in a loop. When the loop terminates the program should print the total number of positive and negative values and their sum.

28th Apr 2018, 4:33 PM
Jordan
Jordan  - avatar
1 Answer
+ 2
i don't know c but i can help you in algorithm..first you should declare three variable the sum and assign it to zero and two variable for example pos for positive number and ne for negative number and assign them also to zero because this variable is a count variable use a for loop and put an if the number is less than zero increment the ne by 1 else increment the pos by 1 and you should be sure that zero is not a positive number then increment sum variable by the number..sorry for my poor English.
10th Jul 2018, 8:28 PM
kais hasan
kais hasan - avatar