C Program for beginners
keywords: c program for beginners, multiplication table, c program to print a multiplication table, c program to create multiplication table, product table in c, multiplication table in c++, c program to find product of two numbers, basic c program, c program, c++ program, c program to multiply, multiply numbes in c program,easy c program, c program, first lesson in c program, learn c proamming in 1 hour, x byte lab xbyte, xbytelab, ashiq dey, author ashiq, author dey, easy way write c program to make table, easy c program, how to write a c program, to multiply numbers, to find the product of two no. and c program to find the table of multiplication,like google,google is good,
C program to make a table of multiplication
|
A C/C++ program to make a table of multiplication can be achieved through many ways, here we showed only 2 of them. Before heeding ahead you should know the basic keywords, variables, codding structure etc. If you are new to C Language you can know about them at this link. Still to make the learning process easy to understand, we explained about the program right below the code. To know how to write the main structure of a C program visit this link.
But now you might be wondering that where to write the C program, Don’t worry visit This link and download Dev C++, as it is 23 years old and works perfectly and looks quite modern and is based on GUI.
To know how to save, create new project Visit this link otherwise skip this.
If you are new to C language then without wasting time Visit this link.
Method 1
|
1
|
#include<stdio.h>
|
2
|
main ()
|
3
|
{
|
4
|
int i,n,m,product;;
|
5
|
printf("Enter the no. whose table is to be prepared: ");
|
6
|
scanf("%d",&m);
|
7
|
printf("\n Upto how much: ");
|
8
|
scanf("%d",&n);
|
9
|
for(i = 1; i <= n; i++)
|
10
|
{
|
11
|
product=m*i;
|
12
|
printf("\n %d X %d = %d",m,i,product);
|
13
|
}
|
14
|
return 0;
|
15
|
}
|
Explaination:
1. #include<stdio.h> is used to tell the compiler to include and link standard input output functions in the program from the library before compilation.
2. int is used to say the compiler that the data type is an integer and all variable used in this program should be declared here.
Here i,n,m,product are variables, you can take variables of your choice but you can’t use any numbers, keywords, symbols and spaces in between.
Notice the spaces before int, these spaces are ignored by the compiler and are used for giving a good look and makes the code easy to understand when the program is long and complex, It is achieved by ‘Tab’ key.
At the end of each line we have entered ‘;’ which is similar to a full stop in a sentence
3. ‘i’ is increment variable, i.e. its value will keep on increasing from 0 to n, see line 9
4. printf("\n Enter the no. whose table is to be prepared: ");
printf is a keyword, and it is used to display the contents which lies between “-----” but %d, %c, %f, %s,\n will not be displayed.
5. scanf("%d",&m);
scanf is also a keyword, it is used to read the input of user.
Here scanf will read and store m ‘s value, so when the user types a number and press the Enter, then scanf will read it and store it as a value of m.
Here %d will accept only integer values
NOTE: %d is used for only integers
%c is used for character
To know format other Data Type Visit this link.
6. for(i = 1; i <= n; i++)
For repeating a same thing loop is used in c programs
Here i = 1 means value of i will start from 1, i <= n means value of i will be upto < OR = n, i++ means value of i will increment (increase) fromi=1 to i<=n.
To write something more than 1 line within for loop we should use braces ‘{}’.
7. In product=m*i; all are variables where m=user’s input, and i= increment function i.e. it value will be from 1 to n, as i’s value will depend on what we give within for loop e.g. for(i = 1; i <= n; i++)
8. printf("\n %d X %d = %d",m,i,product);
Here %d=m, %d=i, %d= product and product=which we wrote in formula (line 11)
9. return 0; is used at the end of the program to return a value 0 when the program execution is finshed.
tags: c program for beginners, multiplication table, c program to print a multiplication table, c program to create multiplication table, product table in c, multiplication table in c++, c program to find product of two numbers, basic c program, c program, c++ program, c program to multiply, multiply numbes in c program,easy c program, c program, first lesson in c program, learn c proamming in 1 hour, x byte lab xbyte, xbytelab, ashiq dey, author ashiq, author dey, easy way write c program to make table, easy c program, how to write a c program, to multiply numbers, to find the product of two no. and c program to find the table of multiplication,like google,google is good,
write a c program, to multiply two numbers, to find the product of two no.
Method 2
|
1
|
#include<stdio.h>
|
2
|
main ()
|
3
|
{
|
4
|
int i,n,m;;
|
5
|
printf("Enter the no. whose table is to be prepared: ");
|
6
|
scanf("%d",&m);
|
7
|
printf("\n Upto how much: ");
|
8
|
scanf("%d",&n);
|
9
|
for(i = 1; i <= n; i++)
|
10
|
printf("\n %d X %d = %d",m,i,m*i);
|
11
|
return 0;
|
12
|
}
|
Explaination:
1. in int we have used only three variables because we will write the formula in printf statement itself.
2. This time we wrote the formula in printf statement, and we wrote it within for loop without braces ‘{}’.
3. printf("\n %d X %d = %d",m,i, m*i);
In the formula we should use * sign NOT x Or X, don’t get confused.
tags: c program for beginners, c program to find the sum of two numbers, basic c program, c program, c++ program, c program to add, add noumbes in c program,easy c program, c program, first lesson in c program, learn c proamming in 1 hour, x byte lab.xbyte,xbytelab,ashiq dey, author ashiq, author dey, easy way write c program to add no., easy c program, how to write a c program, to add two numbers, to find the sum of two no.
Good post, It really helped me to learn to code this program within 10-15 minutes for which I was struggling for about 3-4 days, Thanks Code X
ReplyDeleteProgram to Multiply Two Matrices c codes for beginners
ReplyDelete