Write a program that allows the user to choose a number between 1 and 10. Then p
ID: 3757880 • Letter: W
Question
Write a program that allows the user to choose a number between 1 and 10. Then print the corresponding time table
Write a title “Time Table:”
Read in a number between 1 and 10 from the user
Use a for loop to print the time table (see output) Note that the left column is right aligned (the ones line up but the right column is left aligned (one blank after the assignment operator) Hint: %2d print a right aligned column of width 2
Output: Time Table:
Number (1 - 10): 4
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
Lab Time
Explanation / Answer
#include <stdio.h>
int main()
{ int number, i = 1;
printf(" Enter any Number:");
scanf("%d", &number);
printf("time table of %d: ", number);
while (i <= 10)
{
printf(" %d x %d = %d", number, i, number * i);
i++;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.