Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Friday, August 12, 2022

C program to display the multiplication table of the nth term of a given number.

C program to display the multiplication table of the nth term of a given number.

 


C program to display the multiplication table of the nth term of a given number.



Introduction:

Multiplication tables are a fundamental concept in mathematics, and they form the foundation for many mathematical operations. The multiplication table of a given number provides a quick and easy way to see the multiples of that number. In this article, we will explore how to write a C program to display the multiplication table of the nth term of a given number.

First, let's define what we mean by the nth term of a given number. The nth term refers to the product of the given number and the nth integer. For example, the third term of the multiplication table of the number 5 would be 15 (5 x 3 = 15).

Now, let's look at the steps involved in writing a C program to display the multiplication table of the nth term of a given number:


Step 1: Get the input from the user To get the input from the user, we need to use the scanf() function. We will prompt the user to enter the number and the value of n.

Step 2: Calculate the multiplication table To calculate the multiplication table, we need to use a loop. We will use a for loop to iterate from 1 to n and print the product of the number and the current value of the loop variable.

Step 3: Display the multiplication table To display the multiplication table, we need to print the output to the console. We will use the printf() function to display the multiplication table.

Following is the code for C program to display the multiplication table of the nth term of a given number.

#include <stdio.h>
#include<conio.h>
int main()
{
int i,n1,n2,m;
printf("Enter which no table\n");
scanf("%d",&n1);
printf("How many time\n");
scanf("%d",&n2);
for (i=1;i<=n2;i++)
{
printf("\n%dX%d=%d",n1,i,n1*i);
}
return 0;
}

Output:



Conclusion:

In conclusion, the above C program calculates and displays the multiplication table of the nth term of a given number. This program can be used to quickly calculate and display the multiples of any number. By understanding and using this program, you can improve your understanding of multiplication tables and strengthen your programming skills in C.


No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages