1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sweet-ann [11.9K]
3 years ago
7

Write a C++ program to find all numbersless than 1000 which are:

Computers and Technology
1 answer:
Elden [556K]3 years ago
8 0

Answer:

The c++ program is shown below.

#include <iostream>

using namespace std;

int main() {    

   cout<<"Numbers less than 1000 which are divisible by 7"<<endl;    

   for(int k=1; k<1000; k++)

   {

       // number should give remainder 0 which show complete divisibility

       if(k%7 == 0)

           cout<<k<<"\t";

   }    

   cout<<endl<<"Numbers less than 1000 which are divisible by 11"<<endl;    

   for(int k=1; k<1000; k++)

   {

       if(k%11 == 0)

           cout<<k<<"\t";

   }    

   cout<<endl<<"Numbers less than 1000 which are divisible by 7 but not divisible by 11"<<endl;    

   for(int k=1; k<1000; k++)

   {

       // for 11, number should not give remainder 0 which shows incomplete divisibility

       if(k%7 == 0 && k%11 != 0)

           cout<<k<<"\t";

   }    

   cout<<endl<<"Numbers less than 1000 which are divisible by 7 and divisible by 11"<<endl;

   

   for(int k=1; k<1000; k++)

   {

       if(k%7 == 0 && k%11 == 0)

           cout<<k<<"\t";

   }    

   cout<<endl<<"Numbers less than 1000 which are not divisible by 7 and not divisible by 11"<<endl;    

   for(int k=1; k<1000; k++)

   {

       if(k%7 != 0 && k%11 != 0)

           cout<<k<<"\t";

   }    

   return 0;

}

Explanation:

The test for divisibility is done by using the modulus operator which is used as a condition inside the if statement. This test is done inside for loop.

All the numbers from 1 to 999, less than 1000, are divided by 7 and/ or 11 depending on the sub question. Only the numbers which are completely divisible are displayed. Divisible numbers give remainder 0 always.

The divisibility test by 7 is shown below.

cout<<"Numbers less than 1000 divisible by 7"<<endl;    

   for(int k=1; k<1000; k++)

   {

       if(k%7 == 0)

           cout<<k<<"\t";

   }    

In other words, all the numbers divisible by 7 are same as the numbers in the table of 7.

The same logic shown above is applied for other sub questions to test for divisibility by 11 and combination of 7 and 11.

To improve readability, tabs and new lines are inserted at appropriate places.

You might be interested in
You are given a data set with information from 1,000 high school students (of which the following is a part of the data) and ask
serg [7]

Answer:

Classification

Explanation:

Building a machine learning solution that can predict the success of a student in completing a college degree is a binary problem. There are two possible answer: success or not success.  

This brings us to a supervised machine learning problem, where one trains the technique with labeled data whether it is a success or not. Since the target variable is discrete (not continuous), classification technique has to be used.  

3 0
3 years ago
How does a film establish the setting?
ololo11 [35]

Answer:

Establishing Shots are critical in a film. They clue the viewer where this next scene is about to take place. Each time the location of a scene shifts, a new establishing shot does exactly; what its name implies: it establishes where the story will now continue, and fiction writers need to do the same thing.

Explanation:

8 0
3 years ago
A web page typically contains ________, which contains the formatting instructions for displaying the web page.
USPshnik [31]
HTML: Hypertext Markup Language. It's used in conjunction with CSS (Cascading Style Sheets), which implements presentation (adding color, positioning elements, etc.) and JavaScript (you'll often see this referred to as JS), which implements functionality (like clicking on buttons) for webpages.
3 0
4 years ago
Design a flowchart or pseudocode for a program that accepts three numbers from a user and displays a message if the sum of any t
Keith_Richards [23]

Answer:

Hi there! Pseudocode is the process of writing out the high-level structure of the program in simple English terms which acts as a blueprint of how the program will work. The pseudocode for this question is written below.

Explanation:

Prompt user for input 1

Validate input 1

Prompt user for input 2

Validate input 2

Prompt user for input 3

Validate input 3

Perform checks:

If  

 1 and 2 equals 3

 Or

 1 and 3 equals 2

 Or

 2 and 3 equals 1

Display message to user

6 0
3 years ago
A _____ miniature battery operated transmitter that can be propelled through a non-metallic pipe or purpose of locating
Anna11 [10]
I think it is the model ET-2. Not quite sure.
7 0
3 years ago
Other questions:
  • Which of the following is NOT an example of input?
    8·1 answer
  • What is a taskbar?
    5·1 answer
  • The programming interface between an application program and the dbms is usually provided by the
    13·1 answer
  • Name the different type of vegetation found in India ?​
    8·2 answers
  • Which of the following statements is used to terminate the program when closing the frame?
    5·1 answer
  • The conversion of decimal 0.0625 into its binary equivalent. Explain.
    7·1 answer
  • If your microwave oven is a computer, define its Operating System and User Interface.
    12·1 answer
  • I’ll mark brainlest
    14·2 answers
  • Question #3
    15·2 answers
  • Determine which system you would recommend each of the customers use based on their provided user and system specs.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!