Question

In: Computer Science

Write an algorithm that print all numbers that are divisible by 3 between 1000 and 2000

Write an algorithm that print all numbers that are divisible by 3 between 1000 and 2000

Solutions

Expert Solution

Algorithm that print all numbers that are divisble by 3 between 1000 and 2000:-

So, it is given that range to check is between 1000 to 2000. Hence starting position will be 1000 where we start to check and 2000 will be ending point.

Algorithm:-

Step 1: START

Step 2: Start from the 1000 and one by one check that number is divisible by 3 or not untill we reached the number 2000.

Step 3: If number is divisible by 3, print that number.

Step 4: If number is not divisible by 3, don't print anything.

Step 5: END.

C++ program that print all numbers that are divisible by 3 between 1000 and 2000:-

//C++ program that print all numbers that are divisible by 3 between 1000 and 2000

#include<iostream>
using namespace std;

//main function

int main() {
        
        //initiaslising that all numbers that are divisible by 3 between 1000 and 2000.
        
        int starting_pos=1000, ending_pos= 2000;
        
        //declaring i variable to check the number is divisible by 3 or not.
        
        int i;
        
        //range is between 1000 to 2000
        
        for(i=1000;i<=2000;i++)
        {
                
                //checking i is divisible by 3 or not
                
                if(i%3==0)
                
                //printing the divisble values
                
                cout<<i<<" ";
                
        }
        return 0;
}

Output:-


Related Solutions

Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by...
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by sum of the digits in them. For example, 2924 is divisible by (2+9+2+4 = 17). Your program should display all these possible numbers in the given range, and each number should be separated from the other by a space.
(Do the algorithm and flowchart) Write a C++ program that reads integer numbers and print it...
(Do the algorithm and flowchart) Write a C++ program that reads integer numbers and print it in horizontal order of the screen
You MUST use a while loop to print numbers 1-100. If the number is divisible by 3 print Soda instead of the number.
You MUST use a while loop to print numbers 1-100. If the number is divisible by 3 print Soda instead of the number. If the number is divisible by 5 print Pop instead of the number. If the number is divisible by 3 AND 5 print *SP*.Print 10 numbers/words to a line. Display the numbers/words in right-aligned columns. Use printf statements to do this. For example:System.out.printf( "5d", number );    System.out.printf( "5s", "Soda" );Every time there are ten numbers on a...
Java Write a program that displays all the numbers from 100 to 200 that are divisible...
Java Write a program that displays all the numbers from 100 to 200 that are divisible by 5 or 6, but not both Make sure all instructions and outputs for the user are explicit
10. Write a for loop which will print every number evenly divisible by 13 between 1...
10. Write a for loop which will print every number evenly divisible by 13 between 1 and 100, inclusive. Your loop will only increment by 1 each loop so you need an if test to see if each number should be printed. Put each number output on the same line, 1 space apart. 11. Write a while loop which will prompt the user for a number and accept their input and then display this message (assuming number input is 3)...
Write a program that generates all prime numbers between 2 and 1000, using the Sieve of...
Write a program that generates all prime numbers between 2 and 1000, using the Sieve of Eratosthenes method. You can find many articles that describe the method for finding primes in this manner on the Internet. Display all the prime values. This program should be in assembly language.
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than...
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than 1000. The program prints the resulting number. You may only use while loops. Use python language
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than...
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than 1000. The program prints the resulting number. You may only use while loops. Use python language
Using a “for loop” print all even numbers in range from 1 to 1000. Also, please...
Using a “for loop” print all even numbers in range from 1 to 1000. Also, please count and print how many even numbers you have found.
Write a program that finds and prints all of the prime numbers between 3 and X...
Write a program that finds and prints all of the prime numbers between 3 and X (X is input from the user). A prime number is a number such that 1 and itself are the only numbers that evenly divide it (for example, 3, 5, 7, 11, 13, 17, …). One way to solve this problem is to use a doubly nested loop (a loop inside another loop). The outer loop can iterate from 3 to N while the inner...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT