Introduction to Programming Lesson 3. #include #include main ( ) { cout << “ Welcome to Virtual University “; }

Slides:



Advertisements
Similar presentations
Integer Arithmetic. Operator Priority Real Number Arithmetic.
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
A pointer is the memory address of a variable. A memory address is a physical location within a system’s memory space. A pointer variable is variable used.
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.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
Friday, December 08, 2006 “Experience is something you don't get until just after you need it.” - Olivier.
1 CS150 Introduction to Computer Science 1 Arithmetic Operators.
1 Data types, operations, and expressions Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions.
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
Introduction to Computers and Programming - Class 2 1 Introduction to Computers and Programming Class 2 Introduction to C Professor Avi Rosenfeld.
CIS 234: Order of Operations, Shortcut & Other Operators Dr. Ralph D. Westfall February, 2004.
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
1 Introduction to Computers and Programming Class 3 Introduction to C Professor Avi Rosenfeld.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
1  Ex: Declare a variable to store user’s age: int age; Prompt the user to enter his/her age: printf (“ How old are you? “); Read / scan the entered value.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Data representation and Data Types Variables.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Object-Oriented Programming Using C++ Third Edition Chapter 2 Evaluating C++ Expressions.
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.
Simple Data Types and Statements. Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx.
LESSON 6 – Arithmetic Operators
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice:
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA TYPES AND OPERATIONS.
M.T.Stanhope Oct Title : C++ Basics Bolton Institute - Faculty of Technology (Engineering) 1 C++ Basics u Data types. u Variables and Constants.
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
CP104 Introduction to Programming Overview of C Lecture 4__ 1 Assignment Statements An assignment statement is to store a value in a variable variable.
CSC 107 – Programming For Science. The Week’s Goal.
Arithmetic in Pascal A Short Glance We will learn the followings in this chapter Arithmetic operators Order of precedence Assignment statements Arithmetic.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
Primitive Variables.
CSC 107 – Programming For Science. Announcements.
"Give a person a fish and you feed them for a day; teach that person to use the Internet and they won't bother you for weeks.“ --unknown "Treat your password.
Data Types Declarations Expressions Data storage C++ Basics.
Chapter 2 Variables.
COMP Primitive and Class Types Yi Hong May 14, 2015.
Arithmetic Expressions in C++. CSCE 1062 Outline Data declaration {section 2.3} Arithmetic operators in C++ {section 2.6} Mixed data type arithmetic in.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
Variables Symbol representing a place to store information
Chapter 3 – Variables and Arithmetic Operations. First Program – volume of a box /************************************************************/ /* Program.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 2 September 3, 2009.
Chapter 3 The New Math. C++ Data Types simple integral charshort intlong bool floating float double Long double enum address pointer reference structured.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Programming Fundamentals. Summary of Previous Lectures Phases of C++ Environment Data Types cin and cout.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
C Building Block Chapter 2. Variables A variable is a space in the computer’s memory set aside for a certain kind of data and given a name for easy reference.
Introduction to C Programming
1 2. Program Construction in Java. 01 Java basics.
A Sample Program #include using namespace std; int main(void) { cout
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.
CSC Programming for Science Lecture 5: Actual Programming.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Visual Basic Variables
ITEC113 Algorithms and Programming Techniques
Introduction to C++ October 2, 2017.
Introduction to Programming
Intro to Programming Week # 2 Variables/Data type Lecture # 4 & 5
INC 161 , CPE 100 Computer Programming
ENERGY 211 / CME 211 Lecture 5 October 1, 2008.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Programming Fundamental-1
Presentation transcript:

Introduction to Programming Lesson 3

#include #include main ( ) { cout << “ Welcome to Virtual University “; }

Variable Variable X

Variable Pic of the memory Pic of the memory name of the variable

Variable Variable starts with 1.Character 2.Underscore _ (Not Recommended)

Variable Small post box Small post box X

Variable Variable is the name of a location in the memory e.g. x= 2; e.g. x= 2;

Variable In a program a variable has: 1. Name 2. Type 3. Size 4. Value

Assignment Operator = x = 2 X 2

Assignment Operator L.H.S = R.H.S. X+ 3 = y + 4 Wrong Z = x +4 x +4 = Z Wrong

X = 10 ; X = 30 ; X 10 X 30

X = X + 1; X = X 11

Data type int i ; -> Declaration line int i ; -> Declaration line i

#include #include main ( ) { int x ; int y ; int z ; x = 10 ; y = 20 ; z = x + y ; cout << " x = " ; cout << x ; cout << " y = " ; cout << y ; cout << " z =x + y = " ; cout << z ; }

int x, y, z ; int x; int y; int z ;

Data Types 1. int 2. short 3. long 4. float 5. double 6. char

Arithmetic operators Plus+ Minus- Multiply* Divide/ Modulus%

Arithmetic operators i + j x * y a / b a % b

% = Remainder 5 % 2 = 1 2 % 2 = 0

4 / 2 = 2 5 / 2 = ?

Precedence Highest:( ) Highest:( ) Next:*, /, % Next:*, /, % Lowest:+, - Lowest:+, -