954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

input a number, (-) to stop....

here it goes..
example prog. output:

Input a number/s, (-) to stop:
5+6-7+8-9+1-2-1


-the user will input numbers, if he/she inputs a (-) number that will be the time that the program will stop.
-the operations between the numbers should be + and - (alternate).

how will i do the codes in C++?
*urgent:D

jen_
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

You dont seem to show us any effort. But maybe I can give you a clue. Read in numbers and if the number is less than 0 then quit..

joshmo
Posting Whiz in Training
280 posts since Oct 2007
Reputation Points: 19
Solved Threads: 20
 

Take a look at how the getche() function works.

stephen84s
Nearly a Posting Virtuoso
1,443 posts since Jul 2007
Reputation Points: 668
Solved Threads: 154
 

here it goes.. example prog. output:

Input a number/s, (-) to stop: 5+6-7+8-9+1-2-1

-the user will input numbers, if he/she inputs a (-) number that will be the time that the program will stop. -the operations between the numbers should be + and - (alternate).

how will i do the codes in C++? *urgent:D

Hi!
Is this your homework? If so do it yourself.

Any way you may use a while loop and check condition for -ve number. The loop breaks when -ve no. is entered.
If you post your code it will be better for us to help you.

pradhan.nc
Newbie Poster
11 posts since Jun 2008
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You