Computer Science, asked by nain580, 1 year ago

Write a c++ program to input a number. If the number is even print it's square otherwise print it's cube

Answers

Answered by himanshusingh52
4
C++ Program to accept a number and print its square if the number is even otherwise print its cube.



Here I used if and else .


//start
#include
#include
#include
void main()
{clrscr();
int x;
cout<<"Enter the number : ";
cin>>x;
if(x%2==0)
{
cout<<"The number"<}
else
{
cout<<"The number"<}
getch();
}
//end


Press Alt+F9 to compile program.
Then Press Ctrl+F9 to run program.

If you need help ,comment below.

please share this blog to your friends
Similar questions