**8051 code to find a square of first 10 natural numbers and store it in an array.**

In this article let’s learn how to find the square of first 10 natural numbers and store them in an array.

**Algorithm:**

**Code goes here:**

1 |
<br />ORG 0000h<br />LJMP MAIN<br />ORG 40h<br />MAIN: MOV R0,#10H ; memory address where all the squares will be stored<br /> MOV R1,#00 <br />LOOP: INC R1 ;incrementing each time to generate a new square<br /> MOV A,R1 <br /> MOV B,R1<br /> MUL AB ;finding the square of a number<br /> MOV @R0,A ;storing the square of all the numbers in an array<br /> INC R0<br /> CJNE R1,#10,LOOP ; checking the counter value whether it has reached zero<br /> END<br /> |