# include <stdio.h>
# include <iostream>
using namespace std;
int main()
{
    
      int a,b,c;
    while (true)
    {
   
      cout<< " enter ur first digit"<< endl;

      cin>> a;
      
      cout<< "enter ur second digit" << endl;
      
      cin >> b;

      
    

      cout << " ur ans is "<< (a-b) <<endl;
      
      continue ;
      
      break;}
      
      
      

      scanf ("%d%",&c);
       return 0;
       }

this way i can continue the program infinite times but how can i make the user decide if he wants to continue or wants to quit

how does that help me ..what i want to know is how can i quit a program or continue ..

basically what code will be required to do so .

thanks

Your while statement does not check anything. The continue and breaks are inappropriate. Scanf is C and input in c has nothing to do in the program. You can use a do while loop like

# include <stdio.h>
# include <iostream>
using namespace std;
int main()
{
    
      int a,b,c;
	  char ch;

	  do

	  {        
      cout<< " enter ur first digit"<< endl;

      cin>> a;
      
      cout<< "enter ur second digit" << endl;
      
      cin >> b;
	  
      cout << " ur ans is "<< (a-b) <<endl;

	  cout<<"\nDo another? (y/n): ";

	   cin>>ch;
	  }
	  while(ch!='n');
}

The user is asked for yes to continue program and no to terminate it. you can use other loops and a switch case also

[
this way i can continue the program infinite times but how can i make the user decide if he wants to continue or wants to quit

this is a way of doing as you asked to make the user decide - that was what you ask obviously it was not clear sorry

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.