Programming Examples

C program to generate multiplication table for first n number


Write program to generate multiplication table for first ‘n’ number, where ‘n’ is a user input.

Solution

#include<stdio.h>
int main()
{
	int n,a,b;
	printf("Enter the value of n : ");
	scanf("%d",&n);
	for(a=1;a<=n;a++)
	{
		printf("\nTable of %d : ",a);
		for(b=1;b<=10;b++)
		{
			printf("%d \t",a*b);
		}
	}
	return 0;
}
Output

Enter the value of n : 6


Table of 1 : 1  2       3       4       5       6       7       8       9        10

Table of 2 : 2  4       6       8       10      12      14      16      18        20

Table of 3 : 3  6       9       12      15      18      21      24      27        30

Table of 4 : 4  8       12      16      20      24      28      32      36        40

Table of 5 : 5  10      15      20      25      30      35      40      45        50

Table of 6 : 6  12      18      24      30      36      42      48      54        60

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad