# Calculate a square and a square root!

You must make a that outputs the square of the input in one language and the square root of the input in another. The shortest answer in bytes wins!

You must have a precision of at least 3 decimal places, and the input will always be a positive float.

# Octave / Cardinal, 28 bytes

This program squares the input in Cardinal and gets the square root in Octave

 %:=t.
disp(sqrt(input("")))


Try it online! (Octave)

Try it online! (Cardinal)

So % is single line comment in Octave so it just gets input and prints the square root

disp(sqrt(input("")))


So that the Cardinal program doesn't encounter a divide by 0 error and die, the program

%:=t.


has been shifted with a space, which is ignored by both programs

## Explanation of the Cardinal program:

The program starts at the %
It receives input and stores the value as active :
It sets the inactive to be equal to the active =
It multiplies the active by the inactive t
Finally it outputs the active value .

# PHP / JavaScript, 43 bytes

<body onload=alert(<?=$x*$x.')>'.sqrt($x)?>  Input goes like: <?php$x = 10; ?>


Kinda self-explaining, but does it fit the rules? My first code golf tho :-)

• Welcome to code golf! Input must be a float or a string that is only a float. If I understand correctly, this requires separate input. – user58826 Apr 12 '17 at 13:39
• Are you sure this runs as JavaScript? It looks like both versions need a PHP processing stage (JavaScript wouldn't know what to do with alert(<?=$x*$x.')>'.sqrt(\$x)?) – Dave Apr 12 '17 at 19:26

# CGL (CGL Golfing Language) / JS (ES6), 13 bytes(non-competing)

Non-competing because:

1. CGL was released after this question.
2. CGL is not a valid language. Because of ＋ and ⓟ, CGL is technically a valid language.

## Code:

 x=>x**2
//-₂


## JS:

Simple: an anonymous arrow function that returns its first argument squared. The unnamed language code is commented out.

# CGL:

The non-breaking space before the first line acts like a comment. The /s are no-ops. The - in the second line means to decrement the current stack number, which by default is 0. That then sets it to -1, where input is stored. The ₂ replaces the first item in the current stack with its square root, which is now where input is placed. By default, the current stack is outputted, outputting the square root of the input.

• This is 13 bytes. I dunno about CGL, but I'm fairly certain JS uses ascii/utf-8. CGL would probably also use UTF-8, unless it has it's own codepage. – Rɪᴋᴇʀ Apr 13 '17 at 18:46
• @Riker for now, it uses ascii/utf-8. Thanks. – user58826 Apr 13 '17 at 19:28