Answer to Question #180403 in C++ for alizeyh

Question #180403
Write a program that gets a number and prints its cube if it is less than 10 otherwise it should display square of the number.
1
Expert's answer
2021-04-12T05:34:52-0400
#include<iostream>
using namespace std;
int main(){
    int num,sqr,cub;
    cout<<"Enter a number: ";
    cin>>num;
    sqr=num*num;
    cub=num*num*num;
    if(num>0 && num<=10)
    {
        cout<<"Display cube: "<<cub;
    }
    else{
        cout<<"Display Square: "<<sqr;
    }


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS