#include <iostream>
using namespace std;
int main() {
int num;
cout<<"Enter the number to print table: ";
cin>>num;
cout<<"Table Of "<<num<<endl;
for(int i=1; i<=10; i++){
cout<<num<<" x "<<i<<" = "<<num * i<<endl;
}
return 0;
}
Output: 1.The
#include <iostream>
directive includes the input/output stream library that allows us to 2. read input and write output to the console.3. The
4. The
5. The
6. The
7. The
8. The
9. The
10. The
using namespace std
statement indicates that we want to use the standard namespace, which contains standard C++ library functions and objects.4. The
int num
declares an integer variable num
that will store the number whose table we want to print.5. The
cout<<"Enter the number to print table: ";
statement displays the message "Enter the number to print table: " to the console.6. The
cin>>num;
the statement reads an integer input from the user and stores it in the variable num
.7. The
cout<<"Table Of "<<num<<endl;
statement displays the message "Table Of (num)" to the console, where (num)
is the value of the num
variable.8. The
for(int i=1; i<=10; i++)
loop runs 10 times and initializes a loop counter i
to 1, increments it by 1 each time, and checks whether it is less than or equal to 10.9. The
cout<<num<<" x "<<i<<" = "<<num * i<<endl;
statement displays the product of num
and i
in the format "num x i = product" to the console for each iteration of the loop.10. The
return 0;
statement exits the program and returns a value of 0 to the operating system, indicating that the program executed successfully.
No comments:
Post a Comment