gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
Print table using do while loop in c++
- User
Print table using do while loop in c++
- Assistant
Here is an example of printing a table using a do-while loop in C++:
cpp#include <iostream> int main() { int num; std::cout << "Enter a number: "; std::cin >> num; int i = 1; std::cout << "Table of " << num << ":\n"; do { std::cout << num << " x " << i << " = " << num * i << std::endl; i++; } while (i <= 10); return 0; }In this example, the user is prompted to enter a number. The program then uses a do-while loop to iterate from 1 to 10 and print the multiplication table of the entered number.