Lab 3 Variables & Expressions. Basic Operations Addition + Subtraction – Multiplication * Division / Modulus %

Slides:



Advertisements
Similar presentations
Operators and Arithmetic Operations. Operators An operator is a symbol that instructs the code to perform some operations or actions on one or more operands.
Advertisements

Arithmetic Calculations
2 pt 3 pt 4 pt 5pt 1 pt 2 pt 3 pt 4 pt 5 pt 1 pt 2pt 3 pt 4pt 5 pt 1pt 2pt 3 pt 4 pt 5 pt 1 pt 2 pt 3 pt 4pt 5 pt 1pt Integer Addition Integer Subtraction.
Objective: Students will be able to write and solve two- step equations with one variable!
Chapter 3: Expressions and Interactivity. Outline cin object Mathematical expressions Type Conversion and Some coding styles.
1 CSE1301 Computer Programming Lecture 5 C Primitives 2.
Lab 2 Variables in C.
1 CS150 Introduction to Computer Science 1 Arithmetic Operators.
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 – Part 2 Wanda M. Kunkle.
Laws (Properties) of Logarithms
1 Introduction to Computers and Programming Class 3 Introduction to C Professor Avi Rosenfeld.
ICS 103 Lab 2-Arithmetic Expressions. Lab Objectives Learn different arithmetic operators Learn different arithmetic operators Learn how to use arithmetic.
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
Operators and Expressions
CSCI 130 Chapter 4 Statements, Expressions, and Operators.
Chapter 4: Operators Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills /1436.
Simple Data Types and Statements. Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx.
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Unit 3 Lesson 2: Rational Expressions
Arithmetic Operations. Review function statement input/output comment #include data type variable identifier constant declaration.
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 Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Variables, Arithmetic, etc.)
Variables and Expressions, continued CMSC 201. Expressions Anything on the right hand side of the equals is an expression. Expressions can be anything.
Finding Square Roots Grade 8 Ms. Stewart COPY SLIDES WHEN YOU SEE THIS.
CPS120: Introduction to Computer Science Operations Lecture 9.
CP104 Introduction to Programming Overview of C Lecture 4__ 1 Assignment Statements An assignment statement is to store a value in a variable variable.
Arithmetic in Pascal A Short Glance We will learn the followings in this chapter Arithmetic operators Order of precedence Assignment statements Arithmetic.
CHAPTER 2 COMPONENTS OF A PROGRAMMING LANGUAGE I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.
Variables and Expressions, continued CMSC 201. Expressions Anything on the right hand side of an assignment is an expression. An expression is anything.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Data Types Declarations Expressions Data storage C++ Basics.
Khalid Rasheed Shaikh Computer Programming Theory 1.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
Objective - To multiply integers. Signs are the same Signs are different Simplify. 1) 2) 3) 4) 5) 6)
Evaluating Integer Expressions Friday, December 25, 2015.
Order of Operations By Carl Stephen. Order of Operations  Parentheses  Exponents  Square roots  Multiplication  Division  Addition  Subtraction.
Doing math In java.
By: Tameicka James Addition Subtraction Division Multiplication
$100 $200 $300 $400 $100 $200 $300 $400 $300 $200 $100 Writing variable equations Find variables in addition equations Find variables in subtraction.
Dr. Sajib Datta Jan 21,  Declare a variable ◦ int height; [note that no value is still assigned]  Assign a variable a value ◦ height =
NOTE: C programs consist of functions one of which must be main. C programs consist of functions one of which must be main. Every C program begins executing.
Mathematical Manipulation Data types Operator precedence Standard mathematical functions Worked examples.
MATH By: Mr. McTavish. BASIC OPERATIONS  Addition: +  Subtraction: -  Multiplication: *  Division: /  Modulus (division remainder): %
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.
Numeric Data Types There are six numeric data types: byte, short, int, long, float, and double.
Subtracting Integers #41.
Students will be able to:
INSPIRING CREATIVE AND INNOVATIVE MINDS
TMF1414 Introduction to Programming
Addition/ Subtraction
Relational Operations
Assignment statement and Arithmetic operation 2
Arithmetic Operator Operation Example + addition x + y
Algebra Year 10, 2016 Day 1.
1 Step Equation Practice + - x ÷
Order of Operations Using Integers
Algebra Algebra.
EXPRESSIONS We have studied the following in the previous term. 11 = (1 x 10) + 1, 12 = (1 x 10) = (2 x 10) In the above numerical expressions.
EQ: How do I solve an equation in one variable?
Order of Operations Using Integers
Introduction to Programming
Solving Quadratics Using Square Roots
Chapter Sections 1.1 – Study Skills for Success in Mathematics
Chapter 4: Expression and Operator
Number Lines.
Multiply and divide Expressions
Numerical Expression A numerical expression is a string of numbers and operational signs that names a number.
Like Terms.
Presentation transcript:

Lab 3 Variables & Expressions

Basic Operations Addition + Subtraction – Multiplication * Division / Modulus %

Compound Operations x += y;  x = x + y; x -= y;  x = x - y; x *= y;  x= x * y; x /= y;  x = x / y; x++;  x = x + 1; x--;  x = x - 1; x++ and ++x difference?

Float/Integer int a=5; float x; x=a/2; printf("x=%f",x); x=2 ? x 2.52

Operator Precedence ( ) * / % + -

#include Void main(void) { int a=10,b=3,c,d,e,f,g; float y,z; //basic operations c=a+b; d=a-b; e=a*b; f=a/b; g=a%b; Printf(“C=%d\tD=%d\nE=%d\tF=%d\nG=%d\n\n”,c,d,e,f,g); } Example 1

#include Void main(void) { int a=10,b=3,c,d,e,f,g; float y,z; //compound operations c+=a; d-=b; e*=a; f/=b; g++; Printf(“C=%d\tD=%d\nE=%d\tF=%\ d\nG=%d\n\n”,c,d,e,f,g); } Example 2

#include Void main(void) { int a=10,b=3,c,d,e,f,g; float y,z; //integer/ float: is the result correct ? y=b/2; Printf(“Y=%f\n”,y); //what is the order of the operations ? Z=4+5*3; Printf(“z=%f\n\n”,z); } Example 3

Mathematical Functions Use math.h (#include ) Sample functions pow(a,b)a power b (a b ) sin(a)sine of a cos(a)cosine of a sqrt(a)square root of a log(a)Natural logarithm of a log10(a)base-10 logarithm of a