Write a program that continually calculates the cube of a number until the user enters a number that is divisible 2

C++ Program that continually calculates the cube of a number until the user enters a number that is divisible 2

Write a program that continually calculates the cube of a number until the user enters a number that is divisible 2

Object: 

Write a program that continually calculates the cube of a number until the user enters a number that is divisible by both 2 and 3. Expected Output:
Enter a number: 3
Cube of 3 is: 27
Enter a number: 2
Cube of 2 is: 8
Enter a number: 12. C++ projects.

Code:

#include<iostream>
#include<conio.h>

using namespace std;
void main()
{
int sq,num;
while(1)
{
cout<<“Enter Any Number: “;
cin>>num;
if(num%2==0 && num%3==0)
{
break;
}
else if(num!=0)
{
sq=pow(num,3);
cout<<“Cube of “<<num<<” is:”<<sq<<endl;
}
}
getch();
}

#include<iostream>
#include<conio.h>

using namespace std;
void main()
{
	int sq,num;
	while(1)
	{
		cout<<"Enter Any Number: ";
		cin>>num;
		if(num%2==0 && num%3==0)
		{
			break;
		}
		else if(num!=0)
		{
			sq=pow(num,3);
			cout<<"Cube of "<<num<<" is:"<<sq<<endl;
		}
	}
	getch();
}

Output:

Write a program that continually calculates the cube of a number until the user enters a number that is divisible 2

Another Program: Write a C++ program in which user enter his NTS and FSc marks and your program will help student in selection of university.

 

1 thought on “Write a program that continually calculates the cube of a number until the user enters a number that is divisible 2”

  1. Pingback: Write a program that will calculate the selling price of a circuit board that costs $12.67

Leave a Comment

Your email address will not be published. Required fields are marked *