INC 161 , CPE 100 Computer Programming

Slides:



Advertisements
Similar presentations
CSci 1130 Intro to Programming in Java
Advertisements

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.
Introduction to Programming with Java, for Beginners Primitive Types Expressions Statements Variables Strings.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Expressions and Operators Program Style.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Assignment Statements Operator Precedence. ICS111-Java Programming Blanca Polo 2 Assignment, not Equals  An assignment statement changes the value of.
Arithmetic Operations. Review function statement input/output comment #include data type variable identifier constant declaration.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Mathematical Calculations in Java Mrs. G. Chapman.
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
Doing math In java.
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 2 September 3, 2009.
 Most C programs perform calculations using the C arithmetic operators (Fig. 2.9).  Note the use of various special symbols not used in algebra.  The.
Dr. Sajib Datta Jan 21,  Declare a variable ◦ int height; [note that no value is still assigned]  Assign a variable a value ◦ height =
ICS102 Lecture 1 : Expressions and Assignment King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
INC 161 , CPE 100 Computer Programming
Bill Tucker Austin Community College COSC 1315
CSE 220 – C Programming Expressions.
Chapter 2 Variables.
Chapter 2: Introduction to C++
BASIC ELEMENTS OF A COMPUTER PROGRAM
Lecture 4: Expressions and Variables
INC 161 , CPE 100 Computer Programming
Completing the Problem-Solving Process
INSPIRING CREATIVE AND INNOVATIVE MINDS
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
ITEC113 Algorithms and Programming Techniques
What's a Computer? Monitor Disk Main mouse Memory Keyboard Network
Chapter 2 Assignment and Interactive Input
Arithmetic operations & assignment statement
Multiple variables can be created in one declaration
Primitive Data, Variables, Loops (Maybe)
Variables, Expressions, and IO
Introduction to C++ October 2, 2017.
Type Conversion, Constants, and the String Object
Arithmetic Operator Operation Example + addition x + y
OPERATORS (1) CSC 111.
Escape Sequences What if we wanted to print the quote character?
Building Java Programs Chapter 2
Unit 2 Programming.
Lecture 3 Expressions Richard Gesick.
Arithmetic Expressions in C
Introduction to C++ Programming
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Arithmetic Expressions & Data Conversions
Chapter 2 Variables.
CSE 100 Data Types Declarations Displays.
Alternate Version of STARTING OUT WITH C++ 4th Edition
Algorithms computer as the tool process – algorithm
Chapter 2: Introduction to C++.
Data Types and Expressions
INC 161 , CPE 100 Computer Programming
Lecture 4: Expressions and Variables
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
Chapter 2 Variables.
Data Types and Expressions
Arithmetic Expressions & Data Conversions
Data Types and Expressions
Presentation transcript:

INC 161 , CPE 100 Computer Programming Lab 1 Lecturer Associate Prof. Dr. Poj Tangamchit

Facebook Group https://www.facebook.com/groups/138077300115052/ Webpage http://inc.kmutt.ac.th/inc161

Give commands to computers Computer Programming = Give commands to computers

Program = Set of commands Run (open, double click) = send commands to the computer

Please tell you computer to calculate 30 + 120 – 75 2. Common multiplier (ค.ร.น.) of 30,120,75

We want to prepare a set of computer commands (writing a program) by your own

Codeblocks Codeblocks is an integrated development environment (IDE) program. It is a tool for programmer. You can use it to write, run program (set of commands)

C Program Structure main () { } Put commands in here

Sample Program 1 main () { int i; i = 0; i = i+2; i = i *3; i = i -1; }

Run Commands are run in order top-down Commands are run one-by-one main () { int i; i = 0; i = i+2; i = i *3; i = i -1; } Commands are run in order top-down Commands are run one-by-one No pause Very fast

Debugger Debugger is a tool used to stop the program and examine its variables Codeblocks has a debugger plugged-in

Syntax Correction Read error messages !!!!! C language has a syntax.

Variable Declaration We can define a part of memory to store data and can give a name to it. Later, we can refer to it by this name. int Integer 1,2,3,0,-1,-2 float Floating-point 12.44, 8.2816 char Character a, b, c, A, B, C

int = integer float = floating point char = character Follow with variable name e.g. int a; float pt; (Every command in C must end with semi-colon)

Constant Number constant e.g. 1, 2, -48 Character constant Single character in quote e.g. ‘a’ ‘P’ Note: Variable name and character constant are different

The Assignment Operator = It will calculate the right side of = and assign the left side variable to the calculated value. When a floating-point number is assigned to an integer variable, the fractional part will be discarded. > int i; > float d = 10.789; > i = d; (i = 10) e.g. variable = constant variable = variable

Arithmetic Operators There are five arithmetic operators: + Addition - Subtraction * Multiplication / Division % Modulus The multiplication operator * is needed for multiplication. The result of the % operator is the remainder. If the value of the second operand is zero, the behavior is undefined. The operands of the % operator shall have integer type.

Task 1 Define two variables name i and j Make i equal to 3 and j equal to 4 Calculate the sum of i and j and put it in another variable named k Check your result with a debugger