Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am working on a c program. 1. Create a do while loop that tells user a four di

ID: 3663271 • Letter: I

Question

I am working on a c program.

1. Create a do while loop that tells user a four digit number. 2. Then ask user for the 4 digit number. 3. condition the numbers so that if the user does not eneter the correct 4 digit number to print " Incorrect digit" and look again. 4. exit when the digit is correctly entered. This is what I have but I must be missing something. Any help is greatful.

Note: I think I need anotehr variable for the user input and condition statement but not sure.

// Our main function(entry program point)
int main(void)
{
int password;
password = 1010;    // variable
  do{
  printf("This is the 4 digit code: 1010. ");   // Informing user of the 4 digit code
  printf("Please type in 4 digit password: "); // Telling user to input the 4 digit code
  scanf("%d ", &password);    //Scanning the entry of the user for the 4 digit code
} while (password == 1010 );

return 0;
}

Explanation / Answer

int main(void)
{
int password;
password = 1010;    // variable
  printf("This is the 4 digit code: 1010. ");   // Informing user of the 4 digit code
  printf("Please type in 4 digit password: "); // Telling user to input the 4 digit code
  scanf("%d ", &password);

do {

Printf("Password Correct");

} while (password == 1010 );

Printf("Inavlid Password");

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote