How to write (a + b)² in code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to write (a + b)² in code

6th Apr 2023, 1:42 PM
Khushi Kashyap
Khushi Kashyap - avatar
10 Answers
+ 12
Khushi Kashyap if you are talking about in html then we can write in 2 ways:- <p>(a+b)<sup>2</sup></p> <p>(a &plus; b)<sup>2</sup></p>
6th Apr 2023, 3:59 PM
Sakshi
Sakshi - avatar
+ 10
((a*a) + (b*b) + (2*a*b)) beginner friendly😎
6th Apr 2023, 2:47 PM
Aditya Kumar Maurya
Aditya Kumar Maurya - avatar
+ 7
in JS let a = 2 let b = 3 let c = Math.pow(a+b, 2); console.log( c )
6th Apr 2023, 2:52 PM
SoloProg
SoloProg - avatar
+ 6
Specify your programming language
6th Apr 2023, 3:11 PM
Hasnain [ACTIVE CHALLENGER]
Hasnain [ACTIVE CHALLENGER] - avatar
+ 4
Which code specifically like which language
6th Apr 2023, 2:21 PM
Vinome
Vinome - avatar
+ 3
this can apply to several languages including python a=2 b=4 (a+b)**2
6th Apr 2023, 3:10 PM
Vinome
Vinome - avatar
+ 3
let r = 9 let t = 4 let s = Math. pow(r+t , 9); Console.log(s)
6th Apr 2023, 5:11 PM
ASIM FARHEEN ❄️⚡⚡🤳⚡⚡❄️
ASIM FARHEEN ❄️⚡⚡🤳⚡⚡❄️ - avatar
+ 3
In java you can write as math.pow(a+b, 2)
7th Apr 2023, 6:17 AM
Jeevan
Jeevan - avatar
+ 2
use unicode character for ² which is \u00b2
8th Apr 2023, 1:12 PM
I am offline
I am offline - avatar
0
Most of you are not into python here
8th Apr 2023, 11:12 AM
Manuel Buchi
Manuel Buchi - avatar