0% found this document useful (0 votes)
124 views

LQ2 Arrays and Procedures

This document contains pseudocode for two procedures - one for manipulating integers and performing calculations, and one for manipulating arrays and performing calculations based on input values. The integer procedure defines functions for performing calculations on input integer values and manipulating their order or values. The array procedure defines cases to perform different operations on arrays like resizing, assigning values, and calculating sums based on input single values and an integer value.

Uploaded by

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

LQ2 Arrays and Procedures

This document contains pseudocode for two procedures - one for manipulating integers and performing calculations, and one for manipulating arrays and performing calculations based on input values. The integer procedure defines functions for performing calculations on input integer values and manipulating their order or values. The array procedure defines cases to perform different operations on arrays like resizing, assigning values, and calculating sums based on input single values and an integer value.

Uploaded by

Karen Lovedorial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Name: __________________________________________ Signature: __________________ Group#: __________

A. PROCEDURES

Dim intErnet, Sum As Integer


Sub Main()
Dim intA As Integer = Console.ReadLine
Dim intB As Integer = Console.ReadLine
intErnet = Func(intB, intA)
'input values for intA and intB, respectively
'a. 2 4
'b. 5 2
'c. 1.5 5

Select Case intErnet


Case 5
Call Lay(intA, intB)
Call Lay(intB, intA)
Case 2 To 6
Call Bog(intB)
intA = Hall(intB, Hall(intA, intB))
Case Else
Call Lay(intA, intB)
End Select
Console.WriteLine(intA)
Console.WriteLine(intB)
Console.WriteLine(intErnet)
Console.WriteLine(Sum)
Console.ReadLine()
End Sub
Function Func(ByVal Y As Integer, ByVal X As Integer) As Integer
Dim intCounter As Integer
For intCounter = 1 To Y Step (X / 2)
Sum += Sum - X
intCounter += 1.5
Next
Return intCounter
End Function
Function Hall(ByVal X As Integer, ByVal Y As Integer) As Integer
X += 1
Y -= 1
If X >= Y Then
Return X - Y
Else
Hall = X + Y
Exit Function
End If
End Function
Sub Lay(ByRef X As Integer, ByVal Y As Integer)
X *= 2
Y *= 2
If Y > X Then
Call Bog(Y)
Sum += Y
End If
End Sub
Sub Bog(ByRef X As Integer)
Dim temp As Integer
temp = X
X = intErnet
intErnet = temp
End Sub
B. ARRAYS

Sub Main()
Dim intArray() As Integer = {1, 5, 6}
Dim intFixed(2) As Integer
Dim sngA As Single = Console.ReadLine()
Dim sngB As Single = Console.ReadLine()
Dim intN As Integer = Console.ReadLine()
Dim sngSum As Single = 0
'input values for sngA, sngB and intN, respectively
'a. 1 9 3
'b. 1 1 4
'c. 1 8 3

Select Case Math.Round((sngB \ sngA - 1), 0)


Case 0
ReDim intArray(intN - 1)
intArray(intN - 1) = sngA + sngB
For intCounter As Integer = 0 To (intN - 1)
sngSum += intArray(intCounter)
Next
Case Is < 5
For intCounter As Integer = 0 To UBound(intFixed)
intFixed(intCounter) = intArray(intCounter) + sngB
Next
sngSum = intFixed(1) + intFixed(2) + sngA
Case 2, 5, 8
ReDim Preserve intArray(intN - 1)
For intCounter As Integer = 1 To UBound(intArray)
intArray(intCounter) = 1
Next
For intCounter = 0 To (intN - 1)
sngSum += intArray(intCounter)
Next
Case Else
ReDim Preserve intArray(sngB)
sngSum = intArray(0) + intArray(2) + intArray(sngB)
End Select
Console.WriteLine("TestExpression = " & CStr(Math.Round((sngB \ sngA - 1), 0)))
Console.WriteLine("sngSum = " & CStr(sngSum))
Console.WriteLine("intArray(" & (UBound(intArray) & ") = " & CStr(intArray(UBound(intArray)))))
Console.WriteLine("intFixed(" & (UBound(intFixed) & ") = " & CStr(intFixed(UBound(intFixed)))))
'List the final elements of intArray and intFixed for each set of inputs

End Sub

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy