Need to modify this program to let the user type y or Y for yes and n or N for n
ID: 3620557 • Letter: N
Question
Need to modify this program to let the user type y or Y for yes and n or N for no to repeat as many times as possible: Need it for C++, i remove the printf with no issue but when replacing the scanf with cin>> i have an error. #include using namespace std;int main()
{
int n;
int units;
int tens;
printf("Enter a two-digit number:");
scanf("%d",&n);
while(n!=0)
{
while(n<10||n>99)
{printf("Enter a two-digit number: ");
scanf("%d",&n);
}
printf(" You entered the number ");
units=n%10;
tens=n/10;
switch(tens)
{ case 1: switch(units)
{ case 9:printf("nineteen");
break;
case 8: printf("eighteen");
break;
case 7: printf("seventeen");
break;
case 6: printf("sixteen");
break;
case 5: printf("fifteen");
break;
case 4: printf("fourteen");
break;
case 3: printf("thirteen");
break;
case 2: printf("twelve");
break;
case 1: printf("eleven");
break;
case 0: printf("ten");
break;
}
break;
case 2: printf("twenty");
break;
case 3: printf("thirty");
break;
case 4: printf("forty");
break;
case 5: printf("fifty");
break;
case 6: printf("sixty");
break;
case 7: printf("seventy");
break;
case 8: printf("eighty");
break;
case 9: printf("ninty");
break;
}
if(n>20)
{switch(units)
{ case 9: printf("-nine");
break;
case 8: printf("-eight");
break;
case 7: printf("-sevent");
break;
case 6: printf("-six");
break;
case 5: printf("-five");
break;
case 4: printf("-four");
break;
case 3: printf("-three");
break;
case 2: printf("-two");
break;
case 1: printf("-one");
break;
}
}
return 0;
}
}
Need to modify this program to let the user type y or Y for yes and n or N for no to repeat as many times as possible: Need it for C++, i remove the printf with no issue but when replacing the scanf with cin>> i have an error. #include
Explanation / Answer
please rate - thanks you want C++, are you sure you want to use scanf and printf and not cin and cout?Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.