Day02 A. Young W. Lim Sat. Young W. Lim Day02 A Sat 1 / 12

Similar documents
Day05 A. Young W. Lim Sat. Young W. Lim Day05 A Sat 1 / 14

Day06 A. Young W. Lim Mon. Young W. Lim Day06 A Mon 1 / 16

Day06 A. Young W. Lim Wed. Young W. Lim Day06 A Wed 1 / 26

Day08 A. Young W. Lim Mon. Young W. Lim Day08 A Mon 1 / 27

GAS Tutorial - 6. Expression

Day14 A. Young W. Lim Tue. Young W. Lim Day14 A Tue 1 / 15

Day14 A. Young W. Lim Thr. Young W. Lim Day14 A Thr 1 / 14

Stack Tutorial. Young W. Lim Sat. Young W. Lim Stack Tutorial Sat 1 / 15

Day21 A. Young W. Lim Wed. Young W. Lim Day21 A Wed 1 / 13

C: How to Program. Week /Mar/05

GDB Tutorial. Young W. Lim Thr. Young W. Lim GDB Tutorial Thr 1 / 24

Chapter 2 - Introduction to C Programming

Link 7.A Static Linking

Stack Debugging. Young W. Lim Thr. Young W. Lim Stack Debugging Thr 1 / 12

GDB Tutorial. Young W. Lim Fri. Young W. Lim GDB Tutorial Fri 1 / 24

Logic Haskell Exercises

Accessibility (1A) Young Won Lim 8/22/13

Overview (1A) Young Won Lim 9/14/17

Overview (1A) Young Won Lim 9/9/17

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

GDB Tutorial. Young W. Lim Tue. Young W. Lim GDB Tutorial Tue 1 / 32

HyperGeometric Distribution

Overview (1A) Young Won Lim 9/25/17

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19

Link 7. Dynamic Linking

Chapter 2: Overview of C. Problem Solving & Program Design in C

Arrays. Young W. Lim Mon. Young W. Lim Arrays Mon 1 / 17

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

CC112 Structured Programming

Class (1A) Young Won Lim 9/8/14

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27

Arrays. Young W. Lim Wed. Young W. Lim Arrays Wed 1 / 19

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Algorithms Bubble Sort (1B) Young Won Lim 4/5/18

Chapter 1 & 2 Introduction to C Language

Data Type Fall 2014 Jinkyu Jeong

GAS Tutorial - 4. Sections & Relocation

GAS Tutorial - 7. Directives (2)

Programming for Engineers Introduction to C

Access. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18

Fundamentals of Programming Session 4

C introduction: part 1

Link 8.A Dynamic Linking

Procedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42

Data types, variables, constants

Stack Debugging. Young W. Lim Sat. Young W. Lim Stack Debugging Sat 1 / 40

2. Numbers In, Numbers Out

Structured Programming. Dr. Mohamed Khedr Lecture 4

Pointers (1A) Young Won Lim 11/1/17

Applications of Arrays (1A) Young Won Lim 3/15/17

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

Intermediate Programming, Spring 2017*

Lesson 3 Introduction to Programming in C

Decision Making -Branching. Class Incharge: S. Sasirekha

2. HW/SW Co-design. Young W. Lim Thr. Young W. Lim 2. HW/SW Co-design Thr 1 / 21

Example 3 : using a structure array. Young Won Lim 11/25/17

Applications of Arrays (1A) Young Won Lim 2/11/17

ANSI C Programming Simple Programs

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double

Applications of Pointers (1A) Young Won Lim 12/26/17

2. Numbers In, Numbers Out

Applications of Structures (1A) Young Won Lim 12/8/17

Example 1. Young Won Lim 11/17/17

Pointers (1A) Young Won Lim 1/9/18

Pointers (1A) Young Won Lim 1/5/18

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

Type (1A) Young Won Lim 2/17/18

Full file at C How to Program, 6/e Multiple Choice Test Bank

Computers Programming Course 5. Iulian Năstac

ET156 Introduction to C Programming

CS16 Week 2 Part 2. Kyle Dewey. Thursday, July 5, 12

Example 1 : using 1-d arrays. Young Won Lim 12/13/17

AMCAT Automata Coding Sample Questions And Answers

Fundamentals of Programming. Lecture 3: Introduction to C Programming

CSCI 171 Chapter Outlines

Example 2. Young Won Lim 11/24/17

DECISION MAKING STATEMENTS

Example 3. Young Won Lim 11/22/17

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

Applications of Structures (1A) Young Won Lim 12/4/17

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

Link 4. Relocation. Young W. Lim Wed. Young W. Lim Link 4. Relocation Wed 1 / 22

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

6.096 Introduction to C++ January (IAP) 2009

Lab 3. Pointers Programming Lab (Using C) XU Silei

Lecture 3. More About C

Introduction to C# Applications

File (1A) Young Won Lim 11/25/16

Pointers (1A) Young Won Lim 3/5/18

C Programs: Simple Statements and Expressions

Creating, Compiling and Executing

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga

Introduction to C Language

Control. Young W. Lim Mon. Young W. Lim Control Mon 1 / 16

Unit 3. Constants and Expressions

Programming and Data Structures

Basics of Programming

Transcription:

Day02 A Young W. Lim 2017-10-07 Sat Young W. Lim Day02 A 2017-10-07 Sat 1 / 12

Outline 1 Based on 2 Introduction (2) - Basic Elements Basic Elements in C Programming Young W. Lim Day02 A 2017-10-07 Sat 2 / 12

Based on "C How to Program", Paul Deitel and Harvey Deitel I, the copyright holder of this work, hereby publish it under the following licenses: GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License. CC BY SA This file is licensed under the Creative Commons Attribution ShareAlike 3.0 Unported License. In short: you are free to share and make derivative works of the file under the conditions that you appropriately attribute it, and that you distribute it only under a license compatible with this one. Young W. Lim Day02 A 2017-10-07 Sat 3 / 12

comment and white space comments // : to the end of a line comments /*... */ : start and end every c statement ; (statement terminator) ignore white spaces : spaces, tabs, newlines(enter) a statement across many lines Young W. Lim Day02 A 2017-10-07 Sat 4 / 12

main() # preprocessor directives <stdio.h> file must be included to use printf() must have 1+ functions must always have main() function building block {... } function : many inputs, one output (return value) main() returns an int value (used by the shell) void means no input in main(void) Young W. Lim Day02 A 2017-10-07 Sat 5 / 12

variables a variable is stored in a location in memory a variable of type int can hold numbers without decimal point a variable definition: type + name a variable name : a valid identifier {letter, digits, _} case sensitive : upper case and lower case x =... : writing a new value to x, LHS(Left Hand Side)... = x : reading a curent value of x, RHS(Right Hand Side) access: read or write operation a variable must be defined bedfore it can be accessed Young W. Lim Day02 A 2017-10-07 Sat 6 / 12

characters and strings "xyz..." : string with termination \0 "x" : 1-character string with termination \0 x : a single character escape character \ to provide special meaning to escape sequence escape sequence \n : new line to print \ inside a string : use \\ to print " inside a string : use \" Young W. Lim Day02 A 2017-10-07 Sat 7 / 12

printf() and scanf() printf() is a standard library output function (stdio) scanf() is a standard library input function (stdio) "%d %c %s": format string %d for int type i/o %c for char type i/o %s for string type i/o to print % inside a string : use %% &x : the location of a variable x in memory : address printf(... x...); call by value : printf cannot change x scanf(... &x...); call by refrence : scanf can change x Young W. Lim Day02 A 2017-10-07 Sat 8 / 12

arithmetic operators + addition - subtraction * multiplication / division no power operator (^), use pow(x,y) in <math.h> many mathematical functions in math standard library parenthesis operator precedence from left to right expression Young W. Lim Day02 A 2017-10-07 Sat 9 / 12

equality and relational operators equality operators == equal?!= not equal? relational operators > greater? >= greater or equal? assignment = : LHS <- RHS equality op > relational op > assignment op in precedence level Young W. Lim Day02 A 2017-10-07 Sat 10 / 12

errors Syntax Error: grammatically wrong error messages warning messages note messages Semantic Error: algorithmically wrong Young W. Lim Day02 A 2017-10-07 Sat 11 / 12

secure c programming use printf("%s", "Hello\n"); instead of printf("hello\n"); difference between printf_s and printf printf_s checks the format string for valid formatting characters printf only checks if the format string is a null pointer Young W. Lim Day02 A 2017-10-07 Sat 12 / 12