Answer:
The program to this question as follows:
Program:
#include <iostream> //defining header file
using namespace std;
int main() //defining main method
{
int squ=0,n=0; //defining variable
cout<<"Square between 0 to 100 :"; //message
while(n<100) //loop for calculate Square
{
n=squ*squ; //holing value in n variable
cout<<n<<" "; //print Square
squ++; //increment value by 1
}
cout<<endl; //for new line
n=1; //change the value of n
cout<<"Positive number, which is divisible by 10: "; //message
while (n< 100) //loop for check condition
{
if(n%10==0) //check value is divisible by 10
{
cout<<n<<" ";//print value
}
n++; //increment value of n by 1
}
cout<<endl; //for new line
cout<<"Powers of two less than n: "; //message
n=1; //holing value in n
while (n< 100) //loop for check condition
{
cout<<n<<" ";//print value
n=n*2; //calculate value
}
return 0;
}
Output:
Square between 0 to 100 :0 1 4 9 16 25 36 49 64 81 100
Positive number, which is divisible by 10: 10 20 30 40 50 60 70 80 90
Powers of two less than n: 1 2 4 8 16 32 64
Explanation:
In the above program, two integer variable "squ and n" is defined, then three while loop is declared, which is used to calculate different values, that can be described as follows:
- In the first while loop both "n and squ" variable is used, in which n is used for check range and "squ" is used to calculate the square between 1 to 100.
- The second, while it is used to calculate the positive number, which is divisible by 10, in this only n variable is used, that calculates the value and check its range.
- Then the last while loop is used which is used to calculate the double of the number, which is between 1 to 100 range.