135k views
4 votes
Write a C++ program that uses a while statement and the tab escape sequence \t to print the following table of values:N 1 0*N 1 00*N 1 000*N1 1 0 1 00 1 0002 20 200 20003 30 300 30004 40 400 4000

5 50 500 5000

1 Answer

0 votes

Answer:

#include <iostream>

using namespace std;

int main()

{

cout << "N\t10*N\t100*N\t1000*N" << endl;

int x=1;

while(x<=5){

cout << x <<"\t"<< x*10 <<"\t"<<x*100 <<"\t"<< x*1000 << endl;

x++;

}

return 0;

}

Step-by-step explanation:

Print the header, N 10*N 100*N 1000*N, using \t

Initialize the x as 1. It will be used to control the while loop

Create a while loop that iterates while x is smaller than or equal to 5

Inside the loop, print the required values. After printing, increment the value of x by 1

User Taehyun Park
by
5.7k points