The Program in C++ that takes a number and prints its multiplication table upto 10 is given below:
#include <iostream>
int main() {
int num;
std::cout << "Enter a number: ";
std::cin >> num;
for (int i = 1; i <= 10; i++) {
std::cout << num << " x " << i << " = " << num * i << std::endl;
}
return 0;
}
Output:
Enter a number: 5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
Pro-Tips💡
This program takes an input from the user using std::cin
and stores it in the variable num
.
It then uses a for loop to iterate from 1 to 10 and at each iteration, it calculates the product of num
and i
and prints it to the console using std::cout
. The std::endl
is used to add a new line after each printed result.
The return 0;
statement at the end of the main
function tells the operating system that the program has successfully executed.
You can change the limit of the multiplication table by replacing the value of 10 with the required value in the for loop
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.