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

Write a program that asks the user to enter a number between 1 and 10 then print

ID: 3829006 • Letter: W

Question

Write a program that asks the user to enter a number between 1 and 10 then prints the related multiplication table. The program must ask the user if he wants to continue by choosing another number or quit. NB: You have to run your program then join a screenshot of the execution to your answer file Typical run of the program: Give your proposed number between 1 and 10: 4 The Multiplication Table of 4 is 1 * 4 = 4 2 * 4 = 8 3 * 4 = 12 4 * 4 = 16 5 * 4 = 20 6 * 4 = 24 7 * 4 = 28 8 * 4 = 32 9 * 4 = 36 10 * 4 = 40 Do you want to continue Y/N? Y Give your proposed number between 1 and 10: 7 The Multiplication Table of 7 is 1 * 7 = 7 2 * 7 = 146

Explanation / Answer

#include<stdio.h>

void main() {
   int i, n;
   char ch;
   do {
       printf("Give your proposed between 1 and 10: "); //print statement
       scanf("%d",&n); //accept a number
       printf("The Multiplication Table of %d is ",n); //print header
       for (i = 1; i <= 10; i++) //loop through 1 to 10
           printf("%d * %d = %d ",i, n, (i*n)); //print the table content
       printf("Do you want to continue Y/N? ");//ask for continuation
       do { //this loop verifies tha new chat line or return carriage is not erroniously accepted
               ch = getchar();
       }while(ch == ' ' || ch == EOF || ch==' ');
   }while (ch == 'Y' || ch == 'y'); //repaet if requested

}

I kept the code as simple as possible. I have also commented every lines of the code to make life easy. If incase you face certain confusion or trouble with the solution, please feel free to comment below. I shall be glad to help you.

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