100% found this document useful (1 vote)
168 views

Basic Programming Constructs

Variables are used to store and manipulate data in a program. They must begin with a letter or underscore and cannot be keywords. Constants have fixed values that cannot change at runtime. Literals are hard-coded values in source code like integers, floats, characters, strings, and booleans. Data types specify what kind of data a variable can hold, like integers, characters, strings, objects. The console allows a program to display output and take user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
168 views

Basic Programming Constructs

Variables are used to store and manipulate data in a program. They must begin with a letter or underscore and cannot be keywords. Constants have fixed values that cannot change at runtime. Literals are hard-coded values in source code like integers, floats, characters, strings, and booleans. Data types specify what kind of data a variable can hold, like integers, characters, strings, objects. The console allows a program to display output and take user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

BASIC PROGRAMMING

CONSTRUCTS
WHAT IS A VARIABLE?
VARIABLE
•Programmer-defined word that
holds the value of the user.
•Saves a part of memory to store a
determined value.
RULES IN DECLARING
VARIABLES:
•Must begin with a letter or underscore
(_), then followed by a letter, digit, or
underscore.
•It must not include blanks
RULES IN DECLARING
VARIABLES:
•It must not be the keywords but reserved
words by the language.
•It must not be given a name with the
same name as other functions.
WHAT IS A CONSTANT?
CONSTANT
•Have fixed value that cannot be
changed at runtime.
•To declare a constant, type const
CHARACTER CONSTANTS
•\n– New line
•\t– Horizontal Tab
•\b– Backspace
CHARACTER CONSTANTS
•\a– Alert or beep
• \’– Single quote

•\”– Double quote


CHARACTER CONSTANTS

•\\– Backslash
WHAT IS A
LITERAL?
LITERALS
•They are the values within the
source code of a program
•Literal Constants
• Can be integer numerals, floating
point numerals, characters,
strings, or Boolean values.
INTEGER LITERALS
•They are constants and also
called decimal numerals.
• Examples:
• 235
• 67
• 91
FLOATING POINT LITERALS
•Numbers with decimal, fractions,
and exponents.
• Examples:
• 3.14159
• 6.02e23 // 6.02*10^23
CHARACTER AND STRING
LITERALS
•Non-numeric and string literals
• Examples:
• ‘j’ – character
• “CheriBerry” - String
BOOLEAN LITERALS
•Its either TRUE OR FALSE
VARIABLE DECLARATION
Write V if the variable is valid or IV if it
is not.
1. Jasmin Almarinez
2. 1st
3. First
4. cin
5. abc
6. 1person
7. One
8. _Cheriberry
9. @Grade10
10. Jasmine_
WHAT IS A
DATA TYPE?
DATA TYPE
•Value types and reference types
•Variables should be identified on
what data type it can hold or
included.
CATEGORIES OF DATA TYPE
•Value type – holds the data
within its own memory location
•Reference Type – contains a
pointer to another memory
location that holds the data.
• Examples:
• int ‘i’ = 42;
• char ch = ‘A’;
• bool result =true;
• string str = “Hello”;
• byte[] bytes = {1, 2, 3} ; Reference type
VALUE TYPES
REFERENCE TYPES
REFERENCE DESCRIPTION SIZE
TYPES
Object Base type of all 8+ bytes
types

String Character Array 20+ bytes


WHAT IS A
CONSOLE?
CONSOLE
•A window which users can
interact with a system
program.
•Can input text and display
text
Console.Write/WriteLine
•Console.Write
•Writes text and places the cursor
after the last character
•Console.WriteLine
•Writes text and places the cursor to
the next line.
Console.Read/ReadLine
•A method that can read and write
all basic types
String Concatenation
•Combining two strings and returns
as a result of a new string.
Mixed String Concatenation
•Combining two strings with
different data types.

You might also like