This is the second lesson for beginners for simple multiplication table from 1 to 9 This Program Is going to print multiplication table from 1 to 9
The given below is he code for the program
#include<stdio.h>
int
main(
void
)
{
int
a,b;
/*let a and b act as a integer*/
int
num[10][10];
/*the number 10 in the big bracket is an array , inorder to get the 9 set of row and 9 set of coloumn , we have to add one more array beacause in c programming, one array is always reseverd for the NULL set*/
printf
(
"--------------------------------\n"
);
/*this line gives a design to the user interface*/
printf
(
"\n | 1 2 3 4 5 6 7 8 9\n"
);
/*this line gives a design to the user interface*/
printf
(
"________________________________\n"
);
/*this line gives a design to the user interface*/
/*now we are about to enter for loop*/
for
(a=1;a<=9;a++)
/* integer a is 1, when the 1 consecutive number is added to 1, enter the loop(goto statement untill the statement 11) a is less or equals to 9.But when the statement is flase(i.e a being greater than 9) go to statement 18*/
{
printf
(
"%d |"
,a);
/*this line helps to create the stroke mark in 2nd column in every row*/
for
(b=1;b<=9;b++){
/*b=1, increase the number by 1 untill the b is less or equal to 9.if B becomes greater than 9 go to next line*/
num[a-1][b-1]=a*b;
/* untill the statement is flase , go on to loop for 9 times in B and similarly when the statement is flase ,again go to statement 10 to create for loop. This loop goes on upto 81 time to create 81 different number*/
printf
(
" %2d"
,num[a-1][b-1]);}
/*prints the 81 different number in user's wall*/
printf
(
"\n"
);
}
return
0;
}
0 comments :
Post a Comment