I am after making my program wait before responding to the users input,

what code do i use for this and how do i implement it?

#include <iostream>
using namespace std;

int main()
{
char instuctions = 0;
int A =  0;  // user input 1  
int B = 0;  // user input 2
float total = 0; // total of input 1 and input 2 with addition
float total2 = 0; // total of input 1 and input 2 with subtraction
float total3 = 0;  // total of input 1 and input 2 with division
float total4 = 0;  //  total of input 1 and input 2 with mulitiplaction
int total5 = 0;
int restart = 0;  // continue or exit application
	
cout << "Welcome to the Calculator, " << endl;
	

cout << endl;
loop: // loops the program if user continues

cout << "Enter first Number "; 

cin >> A; // lets the user input first value

cout << endl;
	
cout << "Enter second number ";

cin >> B; // lets the user input second value

cout << endl;
	
total = A + B; // works out addition of A and B

cout << A << " + " << B << " = " << total << endl; 
	
total2 = A - B; // works out subtraction of A and B

cout << A << " - " << B << " = " << total2 << endl;
	
total3 = A / B; // works out division of A and B

cout << A << " divided by " << B << " = " << total3 << endl;
	
total4 = A * B; // works out mulitplaction of A and B

cout << A << " * " << B << " = " << total4 << endl;


cout << endl;

cout << "Press 1 to continue using this calculator or 2 to exit ";

cin >> restart;

		if (restart == 1)

			{

			goto loop;

			}

			else

			{

			return 0;

			}

		
	
}

im after the aplication to say eg. 1 + 1 = 2 wait couple of millieseconds then say 1 * 1 = 1
etc..etc

Are you using Windows or *nix? windows.h has a sleep() function.

See this thread about ways to do it with the ctime header:http://www.daniweb.com/forums/thread233015.html


I know you're not asking for help on this part, but you should reform your goto into a do/while loop. It's a lot easier to follow that way.

goto loop;

im after the aplication to say eg. 1 + 1 = 2 wait couple of millieseconds then say 1 * 1 = 1
etc..etc

Suppose you have 200 goto. Your program will be mess. Avoid them to maxima! That said you can use Jonsca suggestion. Also same header have Sleep() fro pausing in given time. Mentioning your platform helps alot.

void sleep(unsigned int  useconds )
{
    // 1 milliseconds = 1000 microsecond.
    // Windows Sleep uses miliseconds
    // linux usleep uses microsecond
    // and since the default
    // usage of the code was under windows 
    // so the argument is   coming in millisecond.
    usleep( useconds * 1000 );
}

reference

platform is windows

yea i know about the goto loop, i have just started c++ was the only loop i had read about, but the do while loop will work like this. please tell me if im correct and were i have gone wrong if i have
Thank you

int exit = 0; // variable to exit program
do 
{
     /*
     code for all the calculations in here 
     */
       
cout << "press 1 to exit" << endl;
cin >> exit;

} while (exit != 1)


}

i have done the time now, but anther question how do i clear the screen?

it keeps showing my calculations under the last one, but i want to know how to clear the screen of any writing so its just a blank screen again

yup!
That will loop until 1 is being typed in followed by return key :)
What about your original problem now? Solved or not?

yea orginal problem solved thank you now just how to clear the screen of any writing

there might be other methods but this should work!

system("cls")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.