5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Advertisements

Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
CSE202: Lecture 2The Ohio State University1 Variables and C++ Data Types.
Introduction to Programming with Java, for Beginners Primitive Types Expressions Statements Variables Strings.
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Variables Pepper. Variable A variable –box –holds a certain type of value –value inside the box can change Example –A = 2B+1 –Slope = change in y / change.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
CMT Programming Software Applications
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Data types and variables
Introduction to C Programming
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
String Escape Sequences
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Objectives You should be able to describe: Data Types
1 Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class:
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Input & Output: Console
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Java Data Types. Primitive Data Types Java has 8 primitive data types: – char: used to store a single character eg. G – boolean: used to store true or.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
CSE1222: Lecture 2The Ohio State University1. mathExample2.cpp // math example #include using namespace std; int main() { cout
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
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.
COMP Primitive and Class Types Yi Hong May 14, 2015.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
© A+ Computer Science - A reference variable stores the memory address of an object. Monster fred = new Monster(); Monster sally.
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.
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.
MIT AITI Lecture 2 The of Java In the following lectures you will learn the basic structures that make up the Java programming language: »Variables.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
CRE Programming Club Class 2 (Import JJZ543 and Practice Your Typing!)
Primitive Data Types. int This is the type you are familiar with and have been using Stores an integer value (whole number) between -2,147,483,648 (-2.
A Sample Program #include using namespace std; int main(void) { cout
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Copyright © Texas Education Agency, Computer Programming Variables and Data Types.
Week 2 - Wednesday CS 121.
Chapter 2 Basic Computation
Multiple variables can be created in one declaration
Variables and Primative Types
Variables, Expressions, and IO
Engineering Innovation Center
Chapter 2 Basic Computation
Lesson 2: Building Blocks of Programming
IDENTIFIERS CSC 111.
Introduction to Primitive Data types
Coding Concepts (Data- Types)
Chapter # 2 Part 2 Programs And data
Introduction to Primitives
Introduction to Primitives
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.
Data Types and Maths Programming Guides.
Variables and Constants
Introduction to Primitive Data types
Presentation transcript:

5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …

HERE ARE THE 5 BASIC CONCEPTS  Variables  Control Structures  Data Structures  Syntax  Tools

WHAT IS A VARIABLE  Variables are the backbone of any program, and thus the backbone of any programming language.  Generally defined in Computer Programming as a storage location with an associated symbolic name which contains some known or unknown quantity or information (a value)  Summing it up a variable is simply a way to store some sort of information for us to use later, we can retrieve this information by referring to a word that describes this information.

Java behaves differently because of the type of the variables.  These are the Java variables we will work with:  boolean  byte  char  float  int  long  short  double  String

LET’S TRY AN EXAMPLE  Let’s say you visit a website and the first thing they want to do is get your and name so that the next time you visit the site will remember you and welcome you back.  To do this they would put in a little pop-up text box on the screen and ask you for your name – that textbox is going to represent the variable.  Let’s call the text box “yourName” that becomes the symbolic name (or word) for your variable. (remember our original definition)

You will type your name into the text box, that information is stored in the variable “yourName Next comes the value of the variable Value is defined as an expression which cannot be evaluated (this is what will be returned) any furtherexpressionevaluated The program you write using variable would return whatever was typed into that text box. Examples where this is used: Facebook, Twitter, anyplace you go online and sign up/ sign in

LET’S GET MORE SPECIFIC  Variables have different types  Example type in a name as a variable that is recognized as a String  Type in your Age that becomes and Integer or Int  I as for the year you were born (4 digits) that is stored as a Double  Why is this important?

JAVA IS A STRONGLY TYPED LANGUAGE  Java has to know what kind of information is being stored in a variable.  Tying in Java means the program knows exactly what is being stored in a variable  Example: Integer  An Integer in Java means you have a number that won’t have any decimal places, it will be a whole number like 5, 20, -40, 4000, or

INT An int variable holds an integer int num = 2; Unlike double, an int can ONLY hold integers. You cannot store a decimal inside of an int. You can store negative numbers in both ints and doubles however.

SIMPLE EXAMPLE  You want to add two number together let’s say the number 22 and the number 3. Java will behave differently depending on the type of the variable that’s storing this data.  Let me show you what I mean:  If you have defined your variables to be of type Integer, then adding 22 and 3 together will result in the Integer 25. Makes perfect sense right? Of course, this is simple Math.  But what happens if your variables are not Integers, but are Strings ?

WHAT HAPPENS IF  So what if you enter something that isn’t an Integer as an Int  Example you enter a value of $34.75  Java would give you an error code when you compile and you would have to fix it

BOOLEAN A boolean is one of the special Java variables that stores either true or false. I say special because in true and false are actually values that the language recognizes. Here is an example: Boolean x = true;

CHAR  A char variable is a variable that holds a single character. A character is a single letter, number, or symbol. For example, 'A' is a character, so is '1' and '&'. Those are all characters. Let's see what a character variable looks like. Char c = ‘g’; capital letters are not the same as lower case letters and vice versa.

DOUBLE A double variable is one that holds a decimal number. For example: double number = 4.67;

STRING String is not a basic variable it is a little more complicated. String name = “John”; A string variable must have quotes around the value in order for it to be a string. Strings can be made up of one letter, one word, whole sentences, or even entire paragraphs. You can also have empty strings.

STRINGS  A String in Java is a different kind of data type and it behaves differently BECAUSE it is a different type of data.  When we refer to a String in Java (and in many other programming languages) we are treating the data like it’s just a plain old sentence in the English language. A String just represents words (or more specifically letters) all placed in a certain order. That’s all the English language (or any language) is, a series of characters/letters placed in a certain order to give meaning to what you’re writing down.

EXAMPLE OF STRINGS  If you were to have two variables, each defined as Strings and they stored the data “22” and “3” (respectively), what would happen if we added them together?  We would get the String : “223”  What if the two String variables, aren’t storing numbers, we’re storing words. So in variable 1 we store the String “Hello”, and in variable 2 we store the String “World”.

WHY ARE WE TALKING ABOUT ANY OTHER PROGRAMMING LANGUAGES – THIS CLASS IS ABOUT JAVA  Many of the languages are very similar: C+, C++, Python, Objective C  Know one language like Java and the rest can be easily learned