Tuesday, July 3, 2012

Count until a negative number

Assalamu Alaikum. Hope you all are well by the grace of Almighty ALLAH. Today we learn how to count integer number until negative integer number. Take a look at the problem.

Problem: Write a program segment that reads and count until a negative value is read.

Sample Input:
5
6
4
2
1
-5

Sample Output:

Total : 5

Solution:






We can also do this program by the following way...


We can also do this program by do while loop. Take a look at the program.


Thank you all..:)


0 comments:

Post a Comment