answersLogoWhite

0


Best Answer

#include<iostream>

using namespace std;

int main(void)

{

int a;

int b;

{

cout << "Please enter a number: ";

cin >> a;

b = a%2 == 0 ? a*a : a*a*a;

cout << "The result is: " << b << endl;

}

return 0;

}

- - -

//Alternative

#include<iostream>

#include<cmath>

User Avatar

Wiki User

โˆ™ 11y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

โˆ™ 6mo ago

num = int(input("Enter a number: ")) if num % 2 == 0: print("Square of", num, "is", num2) else: print("Cube of", num, "is", num3)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Wap to take a number from the user and print its square if the number is even otherwise incase of odd number print its cube?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

How do you write a program to input the side of a square and print its area and perimeter?

1 CLS 2 PRINT "Please to tell me the length of the side of the square." 3 INPUT S 4 PRINT 5 PRINT "The perimeter of the square is "; 4 * S 6 PRINT 7 PRINT "The area of the square is "; S ^ 2 8 PRINT 9 PRINT "That was truly a total blast. Would you like to play again ? 'Y' or 'N' ." 10 INPUT A$ 11 IF A$ = "Y" or A$ = "y" then PRINT "Goody! " : GOTO 2 12 IF A$ = "N" or A$ = "n" then PRINT "Well OK then. Goodbye": END 13 PRINT: PRINT "Please to type a 'Y' to play again, or a 'N' to quit for now." 14 GOTO 10


What is input in math form?

If you are referring to this in terms of programming, then let's say I built a pgm that will prompt you to input an integer and my pgm will return the square of your "input"Looks like this:Enter a number and I will square it: 1212 squared = 144Here it is in C++ //input-output stream STL //to make sure i dont need to reinvent the wheelint input_number; //allocate memory for the inputint square; //same for the outputint main{cout >input_number;square = input_number^2;cout


Write a program to enter the numbers till the user wants and at the end it should display the count of positive and negative and zeros entered without using array?

1 PRINT "Kindly enter your next number, Master, or 'x' to end and total them up." 2 INPUT a$: IF a$ = "x" or a$ = "X" then GOTO 10 3 K = VAL(a$) 4 If K&lt;0 then neg=neg+1: PRINT: GOTO 1 5 If K&gt;0 then pos=pos+1: PRINT: GOTO 1 6 If K=0 then Z=z+1: PRINT: GOTO 1 10 PRINT: PRINT "Thank you, Master. I cannot express the joy that this exercise has brought me. Here are your results: " 11 PRINT: PRINT "The number of positive numbers you entered was "; pos; "." 12 PRINT: PRINT "The number of negative numbers you entered was "; neg; "." 13 PRINT: PRINT "The number of zeros you entered was "; Z; "." 15 PRINT: PRINT: PRINT "Would you like to play again, Master ?" 16 PRINT "Kindly touch 'x' if no, or any other key if yes. I can hardly wait." 17 Input a$: IF a$ &lt;&gt; "X" and a$ &lt;&gt; "x" then GOTO 20 18 PRINT: PRINT "It has been my pleasure to cavort with you today, Master." 19 PRINT "Y'all come back now, y'hear !" : END 20 PRINT: CLS: PRINT "Oh GOODY! I love this game!" 21 pos=0: neg=0: Z=0 22 GOTO 1


WAP to print esquare 10 natural number?

yo yo as


Who first used the square root symbol?

The symbol &radic; for the square root was first used in print in 1525 inChristoph Rudolff's Coss, which was also the first to use the then-new signs '+' and '-'

Related questions

How do you write a programme in basic to assign a number and print its square?

num%=9 CLS PRINT "The square of: "; num%; " = "; num%*num% END


How do you print square using for loops?

how to print "square" using for loop


Where can you print a Marauders map?

If you found a picture of it you could print it, otherwise you need to buy it from Noble Collection.


Write the program that will ask the user to enter a number of per side of a square and display its outline?

#include&lt;stdio.h&gt; int main() { int side,area of square; print f("Enter the length of side\n"); scan f("%d",&amp;side); area of square=side*side; print f(the area of square is %d\n"area of square); return 0; }


Write a structure algorithm pseudocode to calculate the square of a number inputted your algorithm should accept a number find the square and then print the square amount.?

BeginRead:aSet Sqt=pow(a,1/2)If (a


How do you write a program to input the side of a square and print its area and perimeter?

1 CLS 2 PRINT "Please to tell me the length of the side of the square." 3 INPUT S 4 PRINT 5 PRINT "The perimeter of the square is "; 4 * S 6 PRINT 7 PRINT "The area of the square is "; S ^ 2 8 PRINT 9 PRINT "That was truly a total blast. Would you like to play again ? 'Y' or 'N' ." 10 INPUT A$ 11 IF A$ = "Y" or A$ = "y" then PRINT "Goody! " : GOTO 2 12 IF A$ = "N" or A$ = "n" then PRINT "Well OK then. Goodbye": END 13 PRINT: PRINT "Please to type a 'Y' to play again, or a 'N' to quit for now." 14 GOTO 10


What are other examples of flowcharting?

Design a flowchart that accepts a single value and print BSCS for true result and BSIM otherwise? Design a flowchart that accepts a single value and print BSCS for true result and BSIM otherwise?


Is there any sqra function in qbasic?

PRINT SQR(9) ...output... 3 (Thus, giving you the square root of the number 9; I presume this what your question meant...?)


How do you write psudocode for a program that outputs every number from 0 through 8 along with it's square and cube?

for i = 0 to 8 { print i, i^2, i^3 }


Where is the number located on a Thomas Kinkade print?

The number located on a Thomas Kinkade print signifies that the print is real. Each print is handwritten on. If it starts with S/N it is a standard number, and means there are many of the print available. An A/P stands for artist proof, and is sold by Showcase Dealers and Signature Dealers and only a certain number available.


How many pages are required to print large prime number?

An infinite number of pages are required to print an infinitely large prime number.


How do you resize a window in order to print?

Left click and selcet propertys scroll for the crop format or edit option choose and proceed after be sure to save changes incase you need it for later