global total_score
FUNCTION calculate_average(num1: INTEGER, num2: INTEGER)
average ← (num1 + num2) / 2
RETURN average
END FUNCTION
total_score ← 0
PROCEDURE add_score(score: INTEGER)
total_score ← total_score + score
END PROCEDURE
def calculate_average(num1, num2):
average = (num1 + num2) / 2
return average
total_score = 0
def add_score(score):
global total_score
total_score = total_score + score
static int totalScore = 0;
public static void main(String args[]) {
double average = calculateAverage(5, 7);
System.out.println("Average: " + average);
addScore(10);
System.out.println("Total score: " + totalScore);
}
public static double calculateAverage(int num1, int num2) {
double average = (num1 + num2) / 2.0;
return average;
}
public static void addScore(int score) {
totalScore = totalScore + score;
}
Dim totalScore As Integer = 0
Dim average As Double = CalculateAverage(5, 7)
Console.WriteLine("Average: " & average)
AddScore(10)
Console.WriteLine("Total score: " & totalScore)
Function CalculateAverage(num1 As Integer, num2 As Integer) As Double
Dim average As Double = (num1 + num2) / 2.0
Return average
End Function
Sub AddScore(score As Integer)
totalScore = totalScore + score
End Sub
92 docs|30 tests
|
|
Explore Courses for Year 11 exam
|