Ask Question
18 March, 09:04

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

1) Divisible by 7?

2) Divisible by 11?

3) Divisible by 7 but not divisible by 11?

4) Divisible by both 7 and 11?

5) Notdivisible by 7 or 11?.

+4
Answers (1)
  1. 18 March, 10:48
    0
    The c+ + program is shown below.

    #include

    using namespace std;

    int main () {

    cout<<"Numbers less than 1000 which are divisible by 7"<
    for (int k=1; k<1000; k++)

    {

    / / number should give remainder 0 which show complete divisibility

    if (k%7 = = 0)

    cout<
    }

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

    {

    if (k%11 = = 0)

    cout<
    }

    cout<
    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<
    }

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

    {

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

    cout<
    }

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

    {

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

    cout<
    }

    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"<
    for (int k=1; k<1000; k++)

    {

    if (k%7 = = 0)

    cout<
    }

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a C+ + program to find all numbersless than 1000 which are: 1) Divisible by 7? 2) Divisible by 11? 3) Divisible by 7 but not ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers