Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main ()
{
int a, b, c;
int num1, num2, num3, num4, num5, num6;
char choice;
do
{
cout << "Welcome!\n";
cout << "Enter three unique digits (0 through 9)." << endl;
cout << "Enter digit 1: ";
cin >> a;
cout << "Enter digit 2: ";
cin >> b;
cout << "Enter dight 3: ";
cin >> c;
num1= a*100 + b*10 +c;
num2= b*100 + a*10 +c;
num3= c*100 + a + b*10;
num4= c*10 + a + b*100;
num5= a*100 + b + c*10;
num6= a*10 + b + c*100;
cout << "The six new numbers: "<< endl;
cout << num1 << endl;
cout << num2 << endl;
cout << num3 << endl;
cout << num4 << endl;
cout << num5 << endl;
cout << num6 << endl;
//initializing sum and adding the six unique digits
int sum;
sum = num1 + num2 + num3 + num4 + num5 + num6;
cout<< "Sum of the six new numbers: " <<sum << endl;
cout << "Would you like to run it again? (y/n) : " << endl;
cin>>choice;
}
while (choice == 'y' || choice == 'Y');
return 0; //ends program successfully
}
I added this:
at the start, and
this:
Code:
cin>>choice;
}
while (choice == 'y' || choice == 'Y');
at the end.
EDIT: beaten