An Introduction to Programming

Slides:



Advertisements
Similar presentations
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Advertisements

Data types and variables
CS150 Introduction to Computer Science 1
Chapter 2 Data Types, Declarations, and Displays
JavaScript, Third Edition
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
String Escape Sequences
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
The Real Number System. The natural numbers are the counting numbers, without _______. Whole numbers include the natural numbers and ____________. Integers.
Storing data Getting data out Data types Ruby as a foundation Program Variables Click icon to hear comments (the download may take a minute)
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Objectives You should be able to describe: Data Types
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Lecture #5 Introduction to C++
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Knowledge Base C++ #include using std namespace; int main(){} return 0 ; cout
CSE1222: Lecture 2The Ohio State University1. mathExample2.cpp // math example #include using namespace std; int main() { cout
Fundamental Programming: Fundamental Programming Introduction to C++
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
COMP 171: Data Types John Barr. Review - What is Computer Science? Problem Solving  Recognizing Patterns  If you can find a pattern in the way you solve.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
Variables in Java x = 3;. What is a variable?  A variable is a placeholder in memory used by programmers to store information for a certain amount of.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Data Types Mr Tottman Link. Data Types Programs need to use data for calculations and for output to various devices The best programs will always use.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Chapter # 2 Part 2 Programs And data
Egyptian Language School Computer Department
Topics Designing a Program Input, Processing, and Output
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
BASIC ELEMENTS OF A COMPUTER PROGRAM
Multiple variables can be created in one declaration
Chapter 1. Introduction to Computers and Programming
1 Introduction to Algebra: Integers.
Variables, Expressions, and IO
Unit 2 Smarter Programming.
Constant Variable Expression
Time Manager Class Activity Material Manager Writer leader Communicator Programmer Start a journey from the capital AbuDhabi to Alasmaa School using your.
IDENTIFIERS CSC 111.
Number Systems.
Numbers.
Java Tutotrial for [NLP-AI] 2
CS150 Introduction to Computer Science 1
C++ Data Types Data Type
Chapter 2: Java Fundamentals
Chapter # 2 Part 2 Programs And data
Topics Designing a Program Input, Processing, and Output
7 – Variables, Input and Output
Topics Designing a Program Input, Processing, and Output
Variables Here we go.
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Natural Numbers The first counting numbers Does NOT include zero
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Presentation transcript:

An Introduction to Programming

1.4 Character and String Data Character data (alphanumerics) All the characters you can type at the keyboard A character string (i.e., a string) is a sequence of characters. The data type is String or Character

The Declare Statement Variables should be declared to identify their data type. In this text, a statement such as the following will set aside a space in the computer’s memory to store a variable of a given data type: Declare VariableName As DataType

Declaring String and Character Variables The following statement declares a variable named Response to be of Character data type: Declare Response As Character A Character variable can contain only a single character The following statement declares a variable named UserName to be of String data type: Declare UserName As String A String variable can contain as many characters as desired but the whole string of characters must be enclosed within the quotes. Note that spaces, punctuation, and special symbols such as the %, @, *, and so forth are all considered characters.

Concatenation Concatenation takes two strings and joins them to create a string result The concatenation operator is symbolized, in pseudocode, with a + sign Example: if: String1 = “yellow” and String2 = “duckie” then the statement: Set MyFriend = String1 + String2 results in: MyFriend = “yellowduckie”

1.5 Integer Data Examples: Integers are all the positive, negative, or zero whole numbers Examples: 8 is an integer 8.3 is not an integer -24,567,890 is an integer 0 is an integer 4.0 is not an integer because it has a decimal part

Declaring Integer Variables Each language has a specific way to declare the data type of its variables In this text we use: Declare VariableName As Integer

Initializing Integer Variables Each language has a specific way to initialize (set an initial value) of its variables In this text we use: Set VariableName = value If you try to set a variable to a value that is not of the same type as the variable’s declared data type, you will get an error message.

1.6 Floating Point Data All floating point numbers have both an integer part and a fractional part Examples: 5.65 9.00 -456,784.983 ½ Repeating numbers like 0.333333… Irrational numbers like pi or sqrt(2)

The Declare Statement Revisited In this text we will declare variables with the following data types: To declare a variable named Number1 as a floating point variable use: Declare Number1 As Float To declare a variable named Number2 as an integer variable use: Declare Number2 As Integer To declare a variable named OneLetter as a character variable use: Declare OneLetter As Character To declare a variable named OneWord as a string variable use: Declare OneWord As String

Any Questions ?