C programming - Arithmetic Math table in C

Last updated on June 22nd, 2023 at 03:10 am

This program in C will take a number from the user and then calculate and show the arithmetic table (or math table) of that number. In this program, array has been used. Please, note that we can even show the same output without using array.

C में यह प्रोग्राम user से एक संख्या लेगा और फिर उस संख्या की अंकगणितीय तालिका (या गणित तालिका) की गणना करेगा और दिखाएगा। इस प्रोग्राम में ऐरे का प्रयोग किया गया है। कृपया ध्यान दें कि हम ऐरे का उपयोग किए बिना भी समान आउटपुट दिखा सकते हैं।

C Code screenshot

Lines of code in C

//arithmetic table program in c
#include <stdio.h>
int main()
{
/* declaring an array to hold arithmetic table values, though 10 places would be sufficient, took 11 as array size so that array element 1 to element 10 can be used easily in tandem with i = 1 to i = 10 as 1 to 10 will be used to find the table values.
*/
int table[11];
int n; // to hold the number whose table is to be made

//taking the value of n from the user
printf(“Enter the number of which Table is to be found:\n”);
scanf(“%d”,&n);

//to calculate 10 data of the table and store each in the array
for(int i=1;i<=10;i++)
{
table[i] = n*i;
printf(“saving result number %d as %d\n”, i, table[i]);
}

//printing the table values after fetching array data from elements 1 to 10
printf(“showing table of %d result now………….\n”,n);

for(int i=1;i<=10;i++)
{
//printf(“%d\n”, table[i]);
printf(“%d x %d = %d\n\n”, n, i, table[i]);
}

Output

error: Content is protected !!