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();
}

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.

 

M.A Siddiqui

Hi, I am M.A Siddiqui. I'm a Computer Science Student, In this website, I'm teaching you Multiple languages and provides Projects and other Subjects Notes.

You may also like...

1 Response

  1. May 26, 2020

    […] Another Program: Write a program that continually calculates the cube of a number until the user ent… […]

Leave a Reply

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