Question

In: Computer Science

write a c++ program in which for loop iterates over all integers in the range 0...

write a c++ program in which for loop iterates over all integers in the range 0 to 99 inclusive and prints out all of those numbers dividible by both 2 and 5.

Solutions

Expert Solution

CODE:

OUTPUT:

RAW_CODE:

//including iostream for input and output streams
#include<iostream>
//using standard namespacing
using namespace std;
//staring of the main function
int main()
{
   //integer variable i for purpose of loop iteration
   int i;
   cout<<"The numbers from 0 to 99 , which are divisible by both 2 and 5 are :"<<endl;
   //for loop iterates over all integers in the range 0 to 99
   for(i=0;i<=99;i++)
   {
       //printing the numbers those which are dividible by both 2 and 5
       //In first 0 is printed Zero is divible by everything
       //using logical and(&&) operator it needs both statements to be true
       //if one statement is false then if condition is not executed
       if(i%2==0&&i%5==0)
       {
           cout<<i<<ends;
       }
   }
   //return 0 to the operating system after successful compilation
   return 0;
}

*************For any queries comment me in the comment box**************


Related Solutions

Plase, write program in c++. IP address consists of four integers of range [0, 255] separated...
Plase, write program in c++. IP address consists of four integers of range [0, 255] separated by dots. The next three rows show three correct IP-address: 130.0.0.0 193.197.0.01 255.00.255.255 Write a program that determines whether a given string is a valid IP-address. outpot should be 1 if given IP address is valid, or 0 otherwise.
Write a Console Java program that inserts 25 random integers in the range of 0 to...
Write a Console Java program that inserts 25 random integers in the range of 0 to 100 into a Linked List. (Use SecureRandom class from java.security package. SecureRandom rand = new SecureRandom(); - creates the random number object rand.nextInt(100) - generates random integers in the 0 to 100 range) Using a ListItreator output the contents of the LinkedList in the reverse order. Using a ListItreator output the contents of the LinkedList in the original order.
Write a Console Java program that inserts 25 random integers in the range of 0 to...
Write a Console Java program that inserts 25 random integers in the range of 0 to 100 into a Linked List. (Use SecureRandom class from java.security package. SecureRandom rand = new SecureRandom(); - creates the random number object rand.nextInt(100) - generates random integers in the 0 to 100 range) Using a ListItreator output the contents of the LinkedList in the original order. Using a ListItreator output the contents of the LinkedList in the reverse order.
Write a C++ program that inputs three integers in the range [1..13] that represent a hand...
Write a C++ program that inputs three integers in the range [1..13] that represent a hand of three cards. Your program should output an English evaluation of the hand. In the output, cards will be described as follows: - 2–10 are described by the words for their numeric values: two, three, etc. - 1 is called an ace, 11 is called a jack, 12 is called a queen, and 13 is called a king. The evaluation of a hand is...
Write a Java program using using WHILE loop to find the sum of all integers between...
Write a Java program using using WHILE loop to find the sum of all integers between 200 to 250 which are divisible by 7. Sample Output: Numbers between 200 and 250, divisible by 7: 203 210 217 224 231 238 245 The sum is: 1568
1. Write a C++ program, for.cpp, that reads three integers. The first two specify a range,...
1. Write a C++ program, for.cpp, that reads three integers. The first two specify a range, call them bottom and top, and the other gives a step value. The program should print four sequences using for loops: Each value in the range from bottom to top Each value in the range from top to bottom, reverse counting Every second value in the range from bottom to top Every value from bottom to top increasing by step a: If bottom is...
Program Name: Divisible. Write a program that calculates the number of integers in a range from...
Program Name: Divisible. Write a program that calculates the number of integers in a range from 1 to some user-specified upper bound that are divisible by 3, the sum of those integers, and the number and sum of those integers not divisible by 3. Your program must display meaningful output which includes: the selected upper bound number of integers divisible by 3 sum of integers divisible by 3 number of integers not divisible by 3 sum of integers not divisible...
Program – version 1: Sum of Range Algorithm Write a program that will sum the integers...
Program – version 1: Sum of Range Algorithm Write a program that will sum the integers between a given range (limit your range from 0 to 50). For example, if the user want to add the integers between (and including) 1 and 10, then the program should add: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 Algorithm: Program title/description Ask the user to input a start value in the...
Program Name: Divisible. Write a program that calculates the number of integers in a range from...
Program Name: Divisible. Write a program that calculates the number of integers in a range from 1 to some user-specified upper bound that are divisible by 3, the sum of those integers, and the number and sum of those integers not divisible by 3. Your program must display meaningful output which includes: the selected upper bound number of integers divisible by 3 sum of integers divisible by 3 number of integers not divisible by 3 sum of integers not divisible...
Write a C++ code using while loop which is getting the two integers from the user,...
Write a C++ code using while loop which is getting the two integers from the user, and output how many numbers are multiples of 5, and how many numbers are multiples of 7 between the two integers (inclusive).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT