Question

(C++) Write a program that gets two positive single digit integers from the user. Then print...

(C++) Write a program that gets two positive single digit integers from the user. Then print all the numbers from 1 to 1,000 that are divisible by both of those integers. Print ten numbers per line and separate them by a tab. ('\t')

Ex) Enter two positive single digit integers: 5 6

30 60 90 120 150 180 210 240 270 300

330 360 390 420 450 480 510 540 570 600

630 660 690 720 750 780 810 840 870 900

930 960 990

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:-

CODE:-

#include <iostream>

using namespace std;

int main()
{ int a,b,c=0;
cout<<"enter two one digit number";
cin>>a>>b; //taking 2 number as input
for(int i=1;i<=1000;i++) //To iterate 1000 times
{if(i%a==0 && i%b==0) //checking that number is divisible by a and b
{cout<<i<<"\t";
c++;}
if(c==10) //checking that if in a line 10 numbers are there or not.
{cout<<"\n"; //changing the line.
c=0;}   

}

return 0;
}

CODE SCREENSHOT:-

OUTPUT SCREENSHOT:-

Note:- If any doubt, please write in comment.

Add a comment
Know the answer?
Add Answer to:
(C++) Write a program that gets two positive single digit integers from the user. Then print...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Forecasting method

    Use the moving average method to forecast period 105.Use the exponential smoothing method to forecast period 105.Use the time-series decomposition method to forecast period 105.Comparing the three methods, which one fits this situation best?The larger the parameter (n) is set, the more historical data are taken into account by the moving average.You can choose different parameter (n) to extrapolate to compare the prediction effect.In general, the parameter (n) should not be taken too large.Moving average.153025703560453055106560761085609580106101165012700136701470015760167301776018820197802090021840227702382024800257602676027770287902976030740317203267033690344703567036690376203865039610406204164042590436104460045630466004763048640496105059051610526305366054640558105679057820586505971060700616706269063730647306576066790678106887069890708707189072880739307498075900768607789078880798708084081860829108387084860858408654087780887508978090760917109273093750947509571096750977209877099740100750101760102780103800104850105Exponential smoothingsame153025703560453055106560761085609580106101165012700136701470015760167301776018820197802090021840227702382024800257602676027770287902976030740317203267033690344703567036690376203865039610406204164042590436104460045630466004763048640496105059051610526305366054640558105679057820586505971060700616706269063730647306576066790678106887069890708707189072880739307498075900768607789078880798708084081860829108387084860858408654087780887508978090760917109273093750947509571096750977209877099740100750101760102780103800104850105Time-series decomposition153025703560453055106560761085609580106101165012700136701470015760167301776018820197802090021840227702382024800257602676027770287902976030740317203267033690344703567036690376203865039610406204164042590436104460045630466004763048640496105059051610526305366054640558105679057820586505971060700616706269063730647306576066790678106887069890708707189072880739307498075900768607789078880798708084081860829108387084860858408654087780887508978090760917109273093750947509571096750977209877099740100750101760102780103800104850105

  • I just need help with questions 5 and 6 370 300 630 530 Next SIX questions...

    I just need help with questions 5 and 6 370 300 630 530 Next SIX questions are related to the following data: The following is a random sample of n = 90 undergraduate students' annual textbook expense. 610 600 300 420 520 470 430 520 400 370 730 480 450 500 650 540 330 690 550 450 450 750 750 660 700 770 760 390 680 590 700 580 390 330 320 350 490 310 320 780 370 760 630...

  • Next SIX questions are related to the following data: The following is a random sample of...

    Next SIX questions are related to the following data: The following is a random sample of n = 90 undergraduate students' annual textbook expense. 610 600 300 420 520 470 430 520 400 370 730 480 450 500 650 370 540 330 690 550 450 450 750 750 660 700 300 770 760 390 680 450 590 630 530 700 580 390 330 320 350 490 310 320 780 590 370 470 760 550 630 450 640 620 520 440...

  • C++ Write a program that prompts the user to enter two positive integers: num1 and num2....

    C++ Write a program that prompts the user to enter two positive integers: num1 and num2. - Validate that num1 is less than num2 and that both numbers are positive. If any of these conditions are not met, allow the user to re-enter num1 and num2 until the input is determined valid. - For all integers from num1 through num2, print the word keyboard if the current integer is divisible by 2 and print the word mouse if the current...

  • In C++ Programming: Using a single for loop, output the even numbers between 2 and 1004...

    In C++ Programming: Using a single for loop, output the even numbers between 2 and 1004 (inclusive) that iterates (loops) exactly 502 times. The outputted numbers be aligned in a table with 10 numbers per row. Each column in the table should be 5 characters wide. Do not nest a loop inside of another loop. Hint: First create and test the code that output the numbers all on one line (the command line will automatically wrap the output to new...

  • Implement a method that uses insertion sort to sort numbers. Use the numbers provided in files...

    Implement a method that uses insertion sort to sort numbers. Use the numbers provided in files (100.txt, 1000.txt, 5000.txt, 50000.txt, 100000.txt and 500000.txt) as input. Measure the time taken to sort these numbers (do not include the file IO time). Plot the time taken to sort the numbers [Programming, 35 points] .Files to submit. A report that briefly talks about your solution to each of the problem (the explanation should not exceed more than half pages each). Seperate file for...

  • The Boeing 747 has a cruising altitude of 45,000 feet and cruising speed of 275 m/s....

    The Boeing 747 has a cruising altitude of 45,000 feet and cruising speed of 275 m/s. At this elevation, the temperature and pressure according to the US Standard Atmosphere (air properties as a function of altitude) are 220K and 1.8x104 Pa, respectively. The engines are steady state devices that can be modeled using the 1st Law of Thermodynamics with air (ideal gas) as the working fluid undergoing several processes. a. The inlet area of the engines is 0.5 m2. What...

  • Create a program that will use the attached input file and perform the following operations. Read...

    Create a program that will use the attached input file and perform the following operations. Read the file into an appropriate JCF data structure. Look up a (list of) names and numbers matching a last name or the first letters of a last name, ignoring case. Look up a (list of) names and numbers matching a number or the first digits of a number. Add a name and number to the list. Sort the list by first name, last name...

  • 5) Evaluating Changes in Entropy for an Ideal Gas Air enters a turbine at 427 °C and 1 MPa and ex...

    5) Evaluating Changes in Entropy for an Ideal Gas Air enters a turbine at 427 °C and 1 MPa and exits at 127 °C. The outlet pressure can be tuned by the operator in the range from 300 - 800 kPa. Determine the change in specific entropy of the air, se -si, as it flows through this turbine 3 ways a) Assuming constant specific heats. b) Integrating an appropriate formula from Table A-2(c) from the text, which gives a polynomial...

  • Can somone show me how to do the 1st problem? Need to find the LS and...

    Can somone show me how to do the 1st problem? Need to find the LS and SS for the fit and the LH and SH for the hole. Fits are all SHAFT BASIS METRIC but the shaft and hole diameters can not be used right out of the table. This is because the 3mm shaft tolerance does not match. You will need to lookup the "Fit" from the table, and then use the LS (Largest Shaft) and SS (Smallest Shaft)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT