145k views
3 votes
Write a program using integers usernum and x as input, and output usernum divided by x four times. You should prompt the user with the words: Enter the first integer: at which time the users enters a number, and then Enter the second integer: at which time the user enters the second number. The prompts must be EXACTLY as written, including the colon (:) character, or your test cases will fail. Since you are prompting the user for input, you should not enter anything into the (optional) input box below, but input your numbers after your prompts.

1 Answer

2 votes

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

int usernum,x;

cout<<"Enter the first integer:";

// read first integer

cin>>usernum;

cout<<"Enter the second integer:";

// read second integer

cin>>x;

//divide usernum with x four times and print

cout<<usernum/x<<" "<<usernum/(x*2)<<" "<<usernum/(x*4)<<" "<<usernum/(x*8)<<endl;

return 0;

}

Step-by-step explanation:

Read first integer and assign it variable "usernum" and second integer to variable "x" from user.Divide "usernum" with "x" four time and print the value after each division.

Output:

Enter the first integer:4000

Enter the second integer:2

2000 1000 500 250

User Reirab
by
5.2k points