0% found this document useful (0 votes)
3 views1 page

Code Explain

The document outlines a code snippet that defines a function to check and print odd numbers from a given list. It initializes a list of integers and uses modular arithmetic to determine if specific elements are odd. If they are odd, it prints the numbers and concludes with a statement indicating that all printed numbers are odd.

Uploaded by

stairscaiden
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Code Explain

The document outlines a code snippet that defines a function to check and print odd numbers from a given list. It initializes a list of integers and uses modular arithmetic to determine if specific elements are odd. If they are odd, it prints the numbers and concludes with a statement indicating that all printed numbers are odd.

Uploaded by

stairscaiden
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Code line Code explanation

Function start() { Starts the function


Println(“1”); Prints 1 since it can’t be divided by 2
Var arr = [1,2,3,5,6,7]; Defines the list used in the code later
Var odds = only Runs the function only odds.
Odds(arr);
}
Function only Odds[arr] Run the code to determine if each one is odd or
{ even
Var oddNum = arr[2] % Divides the 2nd one into the list by 2 and takes the
2 remainder
Var oddNumTwo = Divides the 4th one into the list by 2 and takes the
arr[4] % 2 remainder
Var oddNumThree = Divides the 6th one into the list by 2 and takes the
arr[6] % 2 remainder
If(oddNum == 1) { Checks if the oddNum is odd
Println(“3”); Prints the number
}
If(oddNumTwo == 1) { Check if the oddNumTwo is odd
Println(“5”); Prints the number if it is odd
}
If(oddNumThree == 1) Checks if the oddNumThree is odd
{
Println(“7”); Prints the number if it is odd
}
Println(“all these Says that all that was printed is odd
numbers are odd”);
}

You might also like