SlideShare a Scribd company logo
4
Most read
5
Most read
6
Most read
Microsoft® Small BasicVariablesEstimated time to complete this lesson: 1 hour
VariablesIn this lesson, you will learn how to:Define and name a variable.Use variables to store text or numbers.Use arrays to store multiple values.
What is a Variable?You can use a variable to store different kinds of information, such as text or a number. A variable can contain different values at different points in time. Most variables can contain only one value at a time. However, special variables, which are called arrays, can contain more than one value. Let’s look at a program in which you create a variable to store the user’s name. In this example, your program asks the user to type his or her name. Your program uses a variable that is called "name“ to store the information.When you run your program, it displays “Hello” and then the information in the variable.Click the               button on the toolbar.
 How to Name a Variable? You should always start variable names with a letter.
You can use letters, digits, and underscores in the names of your variables.
You should name your variables so that they describe the values that they store.
When you name your variables, you should not include certain reserved words, such as If, For, and Then.You should follow these rules and guidelines when you create your variables.output
Storing Numerical Values In a VariableTo better understand variables that store numbers, let’s write a simple program that calculates the area and perimeter of a rectangle.The program asks the user to specify the length and width of the rectangle. When the user presses ENTER, the program calculates and displays the area and perimeter values of the rectangle.output

More Related Content

PPTX
1.4 conditions and loops
PPT
GUI Programming In Java
PDF
CSS3 Media Queries
PPTX
PHP slides
PPTX
PPT
JavaScript - An Introduction
PPT
Vb introduction.
PDF
Adobe Photoshop Basics - Session 1
1.4 conditions and loops
GUI Programming In Java
CSS3 Media Queries
PHP slides
JavaScript - An Introduction
Vb introduction.
Adobe Photoshop Basics - Session 1

What's hot (20)

PPTX
HTML/HTML5
PDF
Responsive web design
PPTX
1.1 introduction to small basic
PPTX
HTML: Tables and Forms
PPTX
C# Arrays
PPTX
PPTX
1.2 statements, properties, and operations
PPT
Flyweight pattern
PPT
Introduction to Photoshop
PPTX
Web development with django - Basics Presentation
PPT
Oops in PHP
PPT
Graphical User Interface (GUI) - 1
PDF
CSS3, Media Queries, and Responsive Design
PDF
The Power of CSS Flexbox
PPTX
Intro to Flexbox - A Magical CSS Property
PPTX
Basics of the Web Platform
PPT
Scripting languages
PPTX
TUTORIAL ON PHOTOSHOP
PDF
Web Development Course: PHP lecture 1
HTML/HTML5
Responsive web design
1.1 introduction to small basic
HTML: Tables and Forms
C# Arrays
1.2 statements, properties, and operations
Flyweight pattern
Introduction to Photoshop
Web development with django - Basics Presentation
Oops in PHP
Graphical User Interface (GUI) - 1
CSS3, Media Queries, and Responsive Design
The Power of CSS Flexbox
Intro to Flexbox - A Magical CSS Property
Basics of the Web Platform
Scripting languages
TUTORIAL ON PHOTOSHOP
Web Development Course: PHP lecture 1
Ad

Viewers also liked (15)

PPTX
2.5 clock, desktop, and dictionary objects
PPTX
1.5 branching and subroutines
PPTX
2.3 exploring shapes
PPTX
2.4 sound, program, and text objects
PPTX
2.1 graphics window
PPT
Basic logo-command
PPTX
2.2 turtle graphics
DOC
In-bai tap logo_01 (hsinh)
PPTX
DOC
Msw logo application user manual for teacher
DOC
In-bai tap logo_02 -thu tuc (hs)
PPT
Logo primitives
DOC
Geometria de las Tortugas
DOC
In-bai tap logo_02 -thu tuc (gv)
PPT
2.5 clock, desktop, and dictionary objects
1.5 branching and subroutines
2.3 exploring shapes
2.4 sound, program, and text objects
2.1 graphics window
Basic logo-command
2.2 turtle graphics
In-bai tap logo_01 (hsinh)
Msw logo application user manual for teacher
In-bai tap logo_02 -thu tuc (hs)
Logo primitives
Geometria de las Tortugas
In-bai tap logo_02 -thu tuc (gv)
Ad

Similar to 1.3 variables (20)

PPTX
Variable is a symbolic name for information
PPTX
G9 Polaris Programming.pptx algorithm information communication technology
PPTX
Storage in programming
KEY
.NET Variables and Data Types
PPTX
Variables and calculations_chpt_4
PPTX
PLF-Lesson tsu lecture time 2 units-2.pptx
PPTX
Visual Basic Fundamentals
PPTX
Arrays in Data Structure and Algorithm
PPTX
Computer Programming Java VARIABLES.pptx
PDF
Using Variables in Programming
PDF
Using Variables in Programming
PDF
Using Variables in Programming
PPTX
Lecture_01.2.pptx
PDF
Arrays
PPTX
Visual Programming
PPTX
different data types used in programming VB .pptx
PPT
Mesics lecture 8 arrays in 'c'
PPTX
Data types vbnet
PDF
vb.net.pdf
PPTX
Java basics variables
Variable is a symbolic name for information
G9 Polaris Programming.pptx algorithm information communication technology
Storage in programming
.NET Variables and Data Types
Variables and calculations_chpt_4
PLF-Lesson tsu lecture time 2 units-2.pptx
Visual Basic Fundamentals
Arrays in Data Structure and Algorithm
Computer Programming Java VARIABLES.pptx
Using Variables in Programming
Using Variables in Programming
Using Variables in Programming
Lecture_01.2.pptx
Arrays
Visual Programming
different data types used in programming VB .pptx
Mesics lecture 8 arrays in 'c'
Data types vbnet
vb.net.pdf
Java basics variables

More from allenbailey (12)

PPTX
5.1 sharing code
PPTX
4.4 advanced games
PPTX
4.3 collision detection
PPTX
4.2 responding to events
PPTX
4.1 playing with shapes
PPTX
3.6 debugging aids
PPTX
3.5 the controls object
PPTX
3.4 events and interactivity
PPTX
3.3 the math object
PPTX
3.2 stacks and arrays
PPTX
3.1 file input and output
PPTX
2.6 flickr, image list, and network objects
5.1 sharing code
4.4 advanced games
4.3 collision detection
4.2 responding to events
4.1 playing with shapes
3.6 debugging aids
3.5 the controls object
3.4 events and interactivity
3.3 the math object
3.2 stacks and arrays
3.1 file input and output
2.6 flickr, image list, and network objects

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
A Presentation on Artificial Intelligence
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Machine Learning_overview_presentation.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Machine learning based COVID-19 study performance prediction
Unlocking AI with Model Context Protocol (MCP)
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
A Presentation on Artificial Intelligence
sap open course for s4hana steps from ECC to s4
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
A comparative analysis of optical character recognition models for extracting...
20250228 LYD VKU AI Blended-Learning.pptx
Spectroscopy.pptx food analysis technology
Machine Learning_overview_presentation.pptx
The AUB Centre for AI in Media Proposal.docx

1.3 variables

  • 1. Microsoft® Small BasicVariablesEstimated time to complete this lesson: 1 hour
  • 2. VariablesIn this lesson, you will learn how to:Define and name a variable.Use variables to store text or numbers.Use arrays to store multiple values.
  • 3. What is a Variable?You can use a variable to store different kinds of information, such as text or a number. A variable can contain different values at different points in time. Most variables can contain only one value at a time. However, special variables, which are called arrays, can contain more than one value. Let’s look at a program in which you create a variable to store the user’s name. In this example, your program asks the user to type his or her name. Your program uses a variable that is called "name“ to store the information.When you run your program, it displays “Hello” and then the information in the variable.Click the button on the toolbar.
  • 4. How to Name a Variable? You should always start variable names with a letter.
  • 5. You can use letters, digits, and underscores in the names of your variables.
  • 6. You should name your variables so that they describe the values that they store.
  • 7. When you name your variables, you should not include certain reserved words, such as If, For, and Then.You should follow these rules and guidelines when you create your variables.output
  • 8. Storing Numerical Values In a VariableTo better understand variables that store numbers, let’s write a simple program that calculates the area and perimeter of a rectangle.The program asks the user to specify the length and width of the rectangle. When the user presses ENTER, the program calculates and displays the area and perimeter values of the rectangle.output
  • 9. Storing Multiple Values In a VariableYou can store multiple values of the same type in a single variable by using an array. An array is a type of variable that can hold more than one value at a time. Let’s look at an example that uses an array.You can use several other functions of the Array object in your program. You will learn more about these functions later.In this example, you create an array that you name students, and you store three different names in it. You can then retrieve the stored values by using the various operations of the Array object.
  • 10. Let’s Summarize…Congratulations! Now you know how to:Create and name variables, and write statements that contain variables.Use variables to store text or numbers.Use arrays to store multiple values of the same type.
  • 11. Show What You KnowWrite a program that calculates the area and circumference of a circle based on its diameter:Ask the user to specify the diameter of a circle.
  • 12. Create a variable that is called diameter, and store the value from the user in it.
  • 13. Create a variable that is called radius, calculate the circle’s radius, and store the result in that variable.
  • 14. Create variables that are called area and circumference, calculate the area and circumference of the circle, and store the values in those variables.
  • 15. Display the area and circumference of the circle.

Editor's Notes

  • #5: You can identify your variables more easily if you give them suitable names. Code:number_1 = 20number_2 = 30number_sum = number_1 + number_2TextWindow.WriteLine(number_sum)
  • #9: You can use the following formulas for calculation:radius = diameter / 2area = (3.14) * radius * radiuscircumference = (3.14) * 2 * radiusSolution:TextWindow.Write(“What is the diameter of the circle? ")diameter = TextWindow.ReadNumber()radius = diameter / 2area = (3.14) * radius * radiuscircumference = (3.14) * 2 * radiusTextWindow.WriteLine("The area of the circle is " + area + ".")TextWindow.WriteLine("The circumference of the circle is " + circumference + ".")