answersLogoWhite

0

#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

12y ago

What else can I help you with?

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


How do you check a prime number in qbasic?

Cls input "enter the no. You want to check", a if a &lt;=0 then print "only natural nos allowed" if a &lt;=0 end let m = a - 1 for i = m to 2 step -1 if a mod i = 0 then print "not prime" if a mod i = 0 then end next i print "prime" end


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

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


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.?

Oh, dude, like, okay. So, you want a pseudocode to calculate the square of a number? Easy peasy. Here it goes: START ACCEPT number square = number * number PRINT square END There you go, a simple pseudocode to find the square of a number. Hope that helps, man.


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


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


Write a qbasic program to print the squares and cubes of first 10 natural numbers?

10 CLS 20 FOR n = 1 to 10 30 PRINT n, n^2, n^3 40 NEXT n 50 PRINT: PRINT: PRINT "Touch 'x' to go again, any other key to end." 60 INPUT a$ 70 IF a$ = "X" or a$ = "x" THEN 10 80 END


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?


How can I print square photos?

To print square photos, you can adjust the settings on your printer or use photo editing software to crop your photos into a square shape before printing. Make sure to select the appropriate paper size and settings for square prints.


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.