Section 2.7 Basic Program
Learning Objective:
|
Program
Integer Class1, Class2, Class3
Integer average
Integer sum
Display “Enter the number of students in class 1”
Class1 = Input
Display “Enter the number of students in class 2”
Class2 = Input
Display “Enter the number of students in class 3”
Class3 = Input
Sum = Class1 + Class2 + Class3
Average = sum/3
Display “The sum is “, sum, “ and the average is ”, average
Output
Enter the number of students in class 1 |
→ input: 15 |
Enter the number of students in class 2 |
→ input: 20 |
Enter the number of students in class 3 |
→ input: 19 |
The sum is 54 and the average is 18 |
Activity 2.7.1. Activity Coding Exercise.
Save and Run the below program.
Answer.
To find sum and average of three numbers
Exercises Exercises
1. Parsons Problem, Programming.
Rearrange the code blocks below to input two numbers, find the difference and then print it.
You have attempted of activities on this page.