Pseudocode example:
total ← 0
for i ← 1 to 10
input num
total ← total + num
next i
output total
Python example:
total = 0
for i in range(1, 11):
num = int(input("Enter a number: "))
total += num
print("Total:", total)
Java example:
int total = 0;
Scanner scanner = new Scanner(System.in);
for (int i = 1; i <= 10; i++) {
System.out.print("Enter a number: ");
int num = scanner.nextInt();
total += num;
}
System.out.println("Total: " + total);
Visual Basic example:
Dim total As Integer = 0
For i As Integer = 1 To 10
Console.Write("Enter a number: ")
Dim num As Integer = Integer.Parse(Console.ReadLine())
total += num
Next i
Console.WriteLine("Total: " & total)
Pseudocode example:
count ← 0
for i ← 1 to 10
input num
if num > 5 then
ount ← count + 1
end if
next i
output count
Python example:
count = 0
for i in range(1, 11):
num = int(input("Enter a number: "))
if num > 5:
count += 1
print("Count:", count)
Java example:
int count = 0;
Scanner scanner = new Scanner(System.in);
for (int i = 1; i <= 10; i++) {
System.out.print("Enter a number: ");
int num = scanner.nextInt();
if (num > 5) {
count++;
}
}
System.out.println("Count: " + count);
Visual Basic example:
Dim count As Integer = 0
For i As Integer = 1 To 10
Console.Write("Enter a number: ")
Dim num As Integer = Integer.Parse(Console.ReadLine())
If num > 5 Then
count += 1
End If
Next i
Console.WriteLine("Count: " & count)
92 docs|30 tests
|
1. What is the difference between totalling and counting in the context of CIE IGCSE Computer Science? |
2. Can you provide an example of totalling in the context of programming logic? |
3. How is counting important in algorithm design using pseudocode for CIE IGCSE Computer Science? |
4. How can totalling and counting be used in real-world applications outside of programming? |
5. What are some common mistakes students make when working with totalling and counting in CIE IGCSE Computer Science? |
|
Explore Courses for Year 11 exam
|