I have an assignment where we have to write code that finds a number that fits four parameters. My idea was to split up that number into its individual digits, then have an if statement that checks if the number fits the parameters. If it doesn't I wanted it to increase by one and loop until it finds the number. My loop only runs once however, and doesn't even return all four digits. Any direction on what I should do would be appreciated.
#include <iostream>
using namespace std;
int digit_breakdown(int& number);
int main()
{
int number = 1000; //This is the variable I will change to find the secret number
int last_dig, third_dig, sec_dig, first_dig; // These are variables that represent each of the four digits
int secret_number = 0; //This variable holds the secret number
do{
number++;
last_dig = number%10; //This series of code breaks up the number into digits
number /= 10;
third_dig = number%10;
number /= 10;
sec_dig = number%10;
number /= 10;
first_dig = number%10;
number /=10;
if((first_dig != sec_dig) && (first_dig != third_dig) && (first_dig != last_dig) && (sec_dig != third_dig) && (sec_dig != last$
number = secret_number;
}while((secret_number = 0));
cout << "You found the secret number! That number is " << secret_number;
cout << last_dig << endl;
cout << third_dig << endl;
cout << sec_dig << endl;
cout << first_dig << endl;
}
while((secret_number = 0))-- See anything wrong with that line?sec_dig != last$?