Times table. As part of tutoring software that you are building, you need to pri
ID: 3690965 • Letter: T
Question
Times table. As part of tutoring software that you are building, you need to print a times table to the screen. Write a C program that contains an integer num and another integer d. Your program should count the number of digits in num, print the answer, and also print the value of the dth digit of num (counted from the right). If the number is too short to contain a dth digit, an error message should be printed Turn in digits.c. For example, if the number is 23562 and d = 2 your output should be: There are 5 digits in your number And the digit # 2 is 6 If num is 23562 and d = 8 your output should be: There are 5 digits in your number I'm sorry, there is no digit * 8 since there are only 5 total digits Make sure you look up the maximum site of an integer and are sure you are not testing with values that will not fit within the size of the typeExplanation / Answer
4)
#include <stdio.h> // standard header file
#include<stdlib.h> // header file for random number generator
int main() // actual program always starts from main
{
int times[9][9]; // 2D array declaration of size 9 rows and 9 coloumns
int i,j; // integers for loops
printf("Times:1 2 3 4 5 6 7 8 9 "); //format printing
for(i=0;i<9;i++) // for loop for rows
{
for(j=0;j<9;j++) // for loop for coloumns
{
times[i][j]=rand()%70; // random numbers below 70 placing in array
printf("%d %d ",i,times[i][j]); // printing array value
}
printf(" "); // for new line here new row
}
}
5)
#include<stdio.h> // standard library
int main(){ // main program starts here
int num,count=0; // integers for counting digits of num
int d; char c; // dth position in number and character to print positioned value
printf("Enter a number: "); // prompting user to enter a value
scanf("%d",&num); // storing value in num
while(num){ // loop for counting the digits
num=num/10;
count++;
}
printf("Total digits is: %d",count); // printing the total number of digits
printf(" Enter d value:");
scanf("%d",&d); // asking user for position to print
while (d--) { // while loop for position
num /= 10;
}
c=num%10+0; // storing character to print
printf("the # %d digit is %c",d,(num % 10) + '0'); // printing goes here
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.