Skip to main content
Logo image

Section 2.3 Data and Variables

Learning Objective: Student will be able to...
  • Identify the relationship between data and variables
Now that we know what data is and why it is important. How do we use data in our programs? This will be demonstrated through an extension of the previous example. Imagine you are ready to write a program that will find the average number of students in a class. You will most definitely need data. But the question is how do you get the data into your program? One such way is via the user. You start with a prompt, such as “Enter the number of students in class 1”. (A prompt is a short display indicating what the user should do). How might you achieve this you might ask. This is done by telling the computer to present the question on the screen. In this book we will use the keyword Display when writing in pseudocode.
Display “Enter the number of students in class 1”
Using the programming language, C++, we can execute the logic of the pseudocode example

Activity 2.3.1. Activity Coding Exercise.

Save and Run the below program.
Answer.
That is data assignment
You have attempted of activities on this page.