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

Ok so I am having a really hard time with just the last part of my code. If y is

ID: 3590825 • Letter: O

Question

Ok so I am having a really hard time with just the last part of my code.

If y is entered then the whole code should repeat itself.

If n is entered then the program should stop (THAT IS WHERE I AM HAVING THE HARDEST TIME TO GET THE PROGRAM TO STOP ALL TOGETHER I KEEP GETTING AN ERROR)

And if a letter other than y or n is entered then the code has to continuously ask to enter a valid input.

Please make sure your code works by trying it out, thank you!

while (letterToContinueOrStop != 88 letterToContinueOrStop !'n') { rintf("Enter a valid inputln"); rintf( ("Hould you like to perform another calculation? (y/n)" scanf(" %c", &letterToContinueOrStop;); rintf("In"); while (letterToContinueOrStopy return main);

Explanation / Answer

#include <stdio.h>

//main function defination

int main()

{

//varible declaration part

char letterToContinueOrStop;

int check=1;

//loop to check the requirments

while(check)

{

printf("Enter valid input y or n ");

scanf("%c",&letterToContinueOrStop);

//if user entered y

if(letterToContinueOrStop=='y')

{

//place any code you want to run here

printf("input entered - y ");

continue;

}

//if user entered n

else if(letterToContinueOrStop=='n')

{

printf("input entered - n ");

check=0;

break;

}

//if user entered otherthan y or n

else

{

printf("Wrong input entered,Please enter valid input ");

}

}

  

return 0;

}

output:

Enter valid input y or n
y
input entered - y
Enter valid input y or n

Enter valid input y or n
n
input entered - n

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