Command Line Mathematical Table In C, C++ AND Python, Using FOR And While Loops .
Introduction :
Hello programmers and everyone else. My name is ARS and I am going to tell you about encoding to write a basic command line Mathematical Table that takes the value and limit both by user in C, C++ and Python using While and For Loops. it is very easy to learn. But, first you need some other softwares as this tutorial shows you only to how to write a program. So, first download compilers for your platform, either it is android, mac os or Windows. Programming is same on every platform. You can find each compiler HERE. Now you need to install compilers, After setting up compilers, you need to open up a new project and then click new file. Now write the following code on it .
Code for C
Using While Loop.
#include <stdio.h>
#include <conio.h>
void main();
{
clrscr();
printf("Simple Table\n");
int a;
int b;
int c = 1;
printf("Enter Number= \n");
scanf("%d", &a);
printf("Enter Limit= \n");
scanf("%d", &b);
while(c<=b)
{
printf("%d * %d = %d", a, c, a*c);
c++;
}
getche();
}
For Loop.
#include <stdio.h>
#include <conio.h>
void main();
{
clrscr();
printf("Simple Table\n");
int a;
int b;
printf("Enter Number= \n");
scanf("%d", &a);
printf("Enter Limit= \n");
scanf("%d", &b);
for(int c = 1; c <= b; c++;)
{
printf("%d * %d = %d", a, c, a*c);
}
getche();
}
C++ Code
Using While Loop
#include <iostream>
#include <conio.h>
using namespace std;
int main();
{
cout << "Simple Table";
int a;
int b;
int c=1;
cout << "Enter Number= \n";
cin >> a;
cout << "Enter Limit= \n";
cin >> b;
while(c<=b)
{
cout << a, "*", c, "=", a*c;
c++;
}
getche();
}
Using For Loop.
#include <iostream>
#include <conio.h>
using namespace std;
int main();
{
cout << "Simple Table\n";
int a;
int b;
cout << "Enter Number= \n";
cin >> a;
cout << "Enter Limit= \n";
cin >> b;
for(int c=1; c<=b; c++)
{
cout << a, "*", c, "=", a*c;
}
getche();
}
Python Code
Using While Loop.
print("Simple Table\n");
a = int(input("Enter Number=\n"))
b = int(input("Enter Limit=\n"))
c = 1;
while(c <= b):
print(a, "*", c, "=", a*c)
c= c+1;
Using For Loop.
print("Simple Table\n");
a = int(input("Enter Number=\n"))
b = int(input("Enter Limit=\n"))
for c in range(1, b+1):
print(a, "*", c, "=", a*c)