-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix_multiplication_table.c
39 lines (34 loc) · 1.07 KB
/
matrix_multiplication_table.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*DAVIDE GIANNUBILO - Esercizi Linguaggio C
Scrivere un programma che stampi la tabellina di un numero N all'interno di una matrice di dimensione scelta dall'utente
Write a program that prints the multiplication table of a number N (given in input) within a matrix of size chosen by the user
*/
#include<stdio.h>
int main()
{
int row, column, num, cont=0;
do
{
printf("inserisci il numero di righe: ");
scanf("%d",&row);
printf("inserisci il numero di colonne: ");
scanf("%d",&column);
}while(row<=0 || column<=0); //Rows & Columns must be positive and greater than zero
do
{
printf("Inserisci il numero di cui vuoi calcolare le moltiplicazioni successive: ");
scanf("%d", &num);
}while(num!=0); //It cannot be zero
int matrix[row][column];
printf("\nLa matrice sara': \n\n");
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
matrix[i][j]=num*cont;
printf("%3d\t", matrix[i][j]);
cont++;
}
printf("\n");
}
return 0;
}