top of page

How to read code activity

Further to my last article here, I have create a help sheet for students to download and use with a view to translating code snippets into English.

I recommend you spend time with this, setting a series of challenges where you give them a line of code and they translate them into English sentences using whiteboards. This activity would also lend itself to paired or group work where students consider by themselves and then share their answers. You can also download the Word document for free here:





Here are the translations:


int anInt = 5

Declare a variable called ‘anInt’ and copy the value 5 into it.

 

anInt = X + 6

Add 6 to X then copy the answer into the variable ‘anInt’

 

while ((A == -10) && (X != Y))

{

   // DO THIS

}

 

As long as it is true that the value of A is equal to -10 AND value of X is not equal to value of Y, DO THIS

 

while ((D = E) || (E < 10))

{

   // DO THIS

}

 

As long as it is true that D is equal to E OR E is less than 10, DO THIS

 

if (X < 10)

{

    DO THIS

}

else

{

    DO THAT

}

 

If it is true that the value of X is less than 10, DO THIS.

Otherwise

DO THAT

 

do

{

  // DO THIS

 

} while (X < 0)

 

‘DO THIS’, change the value of X and keep repeating that until it is no longer true that the value of X is less than zero

int[] intArray = new int[sizeOfArray]

Declare an array of integers called ‘intArray’ that is the value of ‘sizeOfArray’ in length

 

List[0] = -1

Set the value of the 0th element of List to -1

 

List[X] = A / 2

Do the sum of value of A integer divide 2 and put the answer in the Xth position of List.

 

 

Comments


bottom of page