1st and 3rd September 2015

Similar documents
Primitive Data Types: Intro

C Programs: Simple Statements and Expressions

Using Free Functions

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Datatypes, Variables, and Operations

Programming in C Quick Start! Biostatistics 615 Lecture 4

Expressions and operators

Professor Peter Cheung EEE, Imperial College

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

C++ Programming: From Problem Analysis to Program Design, Third Edition

Lecture 2 Tao Wang 1

Lexical Considerations

Chapter 2: Introduction to C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Lexical Considerations

Creating a C++ Program

Introduction to Programming Using Java (98-388)

1 Lexical Considerations

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Data types Expressions Variables Assignment. COMP1400 Week 2

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

egrapher Language Reference Manual

CHAPTER 3 BASIC INSTRUCTION OF C++

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Visual C# Instructor s Manual Table of Contents

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

REVIEW. The C++ Programming Language. CS 151 Review #2

Exercise: Using Numbers

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Full file at

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

C/C++ Programming for Engineers: Working with Integer Variables

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Overview. Arrays and their properties Creating arrays Accessing array elements Modifying array elements Loops and arrays. Initialization Searching

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

Chapter 2: Using Data

static int min(int a, int b) Returns the smaller of two int values. static double pow(double a,

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

COMP Primitive and Class Types. Yi Hong May 14, 2015

LECTURE 02 INTRODUCTION TO C++

SCoLang - Language Reference Manual

CS16 Exam #1 7/17/ Minutes 100 Points total

CS110: PROGRAMMING LANGUAGE I

SECTION II: LANGUAGE BASICS

ARG! Language Reference Manual

Computational Physics Operating systems

Programming with Java

CSc Introduction to Computing

Objectives. In this chapter, you will:

BASIC ELEMENTS OF A COMPUTER PROGRAM

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

Functions. Functions are everywhere in C. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Procedural Abstraction and Functions That Return a Value. Savitch, Chapter 4

Fundamentals of Programming

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

Preview from Notesale.co.uk Page 2 of 79

C# MOCK TEST C# MOCK TEST I

Computational Expression

DaMPL. Language Reference Manual. Henrique Grando

ENGI Introduction to Computer Programming M A Y 2 8, R E Z A S H A H I D I

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

ECET 264 C Programming Language with Applications

Chapter 6 Primitive types

1.3b Type Conversion

Differentiate Between Keywords and Identifiers

Using Java Classes Fall 2018 Margaret Reid-Miller

Computer Components. Software{ User Programs. Operating System. Hardware

The type of all data used in a C (or C++) program must be specified

INTRODUCTION TO C++ FUNCTIONS. Dept. of Electronic Engineering, NCHU. Original slides are from

6.096 Introduction to C++ January (IAP) 2009

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2

PASS$MOCK$EXAM$ $FOR$PRACTICE$ONLY$

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

Language Reference Manual simplicity

The Math Class (Outsource: Math Class Supplement) Random Numbers. Lab 06 Math Class

QUark Language Reference Manual

CS242 COMPUTER PROGRAMMING

BTE2313. Chapter 2: Introduction to C++ Programming

DEPARTMENT OF MATHS, MJ COLLEGE

Chapter 5 Methods. Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved.

A First Program - Greeting.cpp

Reserved Words and Identifiers

DUBLIN CITY UNIVERSITY

CSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018

Announcements. Lab 1 this week! Homework posted Wednesday (late)

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

The C++ Language. Arizona State University 1

4. Inputting data or messages to a function is called passing data to the function.

Chapter 2 Elementary Programming

Outline. Data and Operations. Data Types. Integral Types

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 2. C++ Basics

CS313D: ADVANCED PROGRAMMING LANGUAGE

Transcription:

1st and 3rd September 2015

Agenda for the week 1 2 3

Math functions and corresponding libraries The standard library has the abs(int) function besides that, the cmath library has the following inbuilt functions: double fabs fabs(double) double sqrt(double) double pow(double, double) example pow(a,n)=a n. double exp(double) log(double) int ceil(double) smallest int the argument. int floor(double) largest int the argument.

Naming convention for identifiers Must start with either an underscore or an alphabet. Example: input. Meaningful names should be chosen. Example: The identifier axb stores the product the a and b. Cannot begin with a digit but can include one in its definition. Example: input 1. Capitilization: Just like Linux, C++ does distinguish between different cases for the identifiers. Example: RATE, rate, rate are all different identifiers. Using keywords as identifiers is prohibited. Example: the identifier int is a reserved word for describing a variable type.

Types of variables char: stores a single symbol within single quotes. int: holds a numeric data type but only holds integers. double: a numeric variable stores a real number. string: stores a string of symbols within the double quotes. Example: string day= Tuesday ; The use of this variables requires the string library. Bool- assumes two values true or false.

classification of variables storing whole numbers short/short int: uses 2 bytes of memory holds a range of 2 15 to 2 15. int: uses 4 bytes of memory holds a range of 2 31 to 2 31. long int: has the same specs as int except for the storage space may differ based on the operating system and the architecture except on a windows os.

classification of variables storing real numbers float: uses 4 bytes of memory holds a range of 10 38 to 10 38 with 7 digits of precision. double: uses 8 bytes of memory holds a range of 10 308 to 10 308 with 15 digits of precision. long double: 10 bytes of memory used with a range of 10 4932 to 10 4932 with 19 digits of precision.

Initialization and declaration of variables Three possible ways to initialize variables a, b, axb. int a = 10 ; ( = can be thought of as an assignment operator.) double b(2.25) ; using the assignment operator and as a result of some operation: Example: double axb = a b ;

Arithmetic Operators Besides the usual +,,, / and % (remainder operator) we have a combination of the assignment operator = with any of the above operators: Example Evaluation of expression count += 2; count= count + 2 total-=discount total = total - discount; bonus*=2; bonus = bonus*2; time/=rush factor time = time/rush factor; change %= 100; change =change %100 amount*=a1 + a2; amount = amount*(a1 + a2)

Evaulation of the operators Unary and assignment operators evaluated right to left given the same precedence other operators left to right. Other precedence rules : 1 Evaluate any expression in (). 2 / 3 4 + 5

if (Boolean Expression) Yes statement ; else No statement ;

Boolean Expression C++ notation Example Evaluation == x+7 == 2 y x+ 7 = 2y!= ans!= 8 ans 8 < discriminant < 0 discriminant <0 <= x <= 0 x 0 > discriminant > 0 discriminant >0 >= x >= 0 x 0 Usage: (2< x) && (y > 6) and operator, (2< x) (y > 6) or operator.