Saturday, May 9, 2009

Using Static for C++?

Write a C++ program that allows user to perform addition or subtraction continuously until the user decides to exit the program. Keep a counter in each of them to accumulate times the function is called





Can someone please help me with this. I have no idea where to start. I just need someone to explain to me what I need to do.





For example, I know I am suppose to have a function for both Addition and Subtraction, but I don't understand how I can make it so it loops itself and exits when the user wants to.





For the counter, I know I am suppose to use the static function, but I don't know where I should put it. Help please?

Using Static for C++?
use a do loop. Or a while loop. When the user enters a number such as a -1 make it break out of the loop. Put the counter inside the loop and make it add one to the counter everytime it goes through.





psedocode...





static int yourcounter





Do


{


//put addition and subtraction code here


//print the answer


// Add one to the counter








} (while num doesnt equal -1);





return;

gift

No comments:

Post a Comment