Week 1 - Friday.  What did we talk about last time?  C basics  Data types  Output with printf()

Slides:



Advertisements
Similar presentations
Overloading Having more than one method with the same name is known as overloading. Overloading is legal in Java as long as each version takes different.
Advertisements

IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
MPI and C-Language Seminars Seminar Plan (1/3)  Aim: Introduce the ‘C’ Programming Language.  Plan to cover: Basic C, and programming techniques.
Introduction to Computers and Programming Lecture 9: For Loops New York University.
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
Display a 12-Month Calendar CS-2301 D-term Programming Assignment #2 12-Month Calendar CS-2301 System Programming C-term 2009 (Slides include materials.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
1 Parts of a Loop (reminder) Every loop will always contain three main elements: –Priming: initialize your variables. –Testing: test against some known.
Loose endsCS-2301, B-Term “Loose Ends” CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language, 2 nd.
"Loose ends"CS-2301 D-term “Loose Ends” CS-2301 System Programming C-term 2009 (Slides include materials from The C Programming Language, 2 nd edition,
C. About the Crash Course Cover sufficient C for simple programs: variables and statements control functions arrays and strings pointers Slides and captured.
CS100A, Fall 1997, Lectures 221 CS100A, Fall 1997 Lecture 22, Tuesday 18 November Introduction To C Goal: Acquire a reading knowledge of basic C. Concepts:
Libraries Programs that other people write that help you. #include // enables C++ #include // enables human-readable text #include // enables math functions.
CS113 Introduction to C Instructor: Ioannis A. Vetsikas
Assignment #2, 12- month Calendar CS-2301, B-Term Programming Assignment #2 12-Month Calendar CS-2301, System Programming for Non-Majors (Slides.
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
Computer Science 210 Computer Organization Introduction to C.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
CS 11 C track: lecture 1 Preliminaries Need a CS cluster account cgi-bin/sysadmin/account_request.cgi Need to know UNIX ITS.
1 COMP 2130 Introduction to Computer Systems Computing Science Thompson Rivers University.
Algorithms and Computing Lecture 3 Control Statements By Dr. M. Tahir Khaleeq.
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
Ruby! Useful as a scripting language – script: A small program meant for one time use – Targeted towards small to medium size projects Use by: – Amazon,
Week 3 - Monday.  What did we talk about last time?  Math library  Preprocessor directives  Lab 2.
Functions in C. Consider #include main() { int i; for(i=1; i
1 計算機程式設計 Introduction to Computer Programming Lecture01: Introduction and Hello World 9/10/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction.
Monday, Jan 13, 2003Kate Gregory with material from Deitel and Deitel Week 2 Questions from Last Week Control Structures Functions Lab 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
Week 3 - Wednesday.  What did we talk about last time?  Other C features  sizeof, const  ASCII table  printf() format strings  Bitwise operations.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Introduction to Programming
Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft RAM Allocation Chapter 3.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CS 100Lecture 211 Announcements P5 due on Thursday FINAL EXAM Tuesday August 10, 8AM, Olin 155 Review sessions on Thursday and Friday Final grades posted.
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 06 – Java Datatypes Webpage:
Week 4 - Monday.  What did we talk about last time?  Precedence  Selection statements  Loops  Lab 3.
THE DOUBLE VARIABLE The double variable can hold very large (or small) numbers. The maximum and minimum values are 17 followed by 307 zero’s.
C Part 1 Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens A History Lesson Development of language by Dennis Ritchie at Bell.
Copyright © Curt Hill Flow of Control A Quick Overview.
Dr. Sajib Datta Jan 21,  Declare a variable ◦ int height; [note that no value is still assigned]  Assign a variable a value ◦ height =
Week 3 - Friday.  What did we talk about last time?  Preprocessor directives  Other C features  sizeof, const  ASCII table  printf() format strings.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Basic Data Types & Memory & Representation. Basic data types Primitive data types are similar to JAVA: char int short long float double Unlike in JAVA,
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Week 2 - Wednesday CS 121.
Computer Science 210 Computer Organization
Week 3 - Friday CS222.
Week 4 - Monday CS222.
Computer Science 210 Computer Organization
Building Java Programs Chapter 2
Lecture 8.
Introduction to Object-Oriented Programming with Java--Wu
IFS410 Advanced Analysis and Design
Introduction to Primitive Data types
Programming Assignment #1 12-Month Calendar—
Scope Rules and Storage Types
CS100A Lecture November 1998 Prelim 3 Statistics Maximum 94
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Variables and Constants
Week 2 - Friday CS222.
Introduction to Primitive Data types
Presentation transcript:

Week 1 - Friday

 What did we talk about last time?  C basics  Data types  Output with printf()

ANSI C retains the basic philosophy that programmers know what they are doing; it only requires that they state their intentions explicitly. Kernighan and Ritchie from The C Programming Language, 2 nd Edition ANSI C retains the basic philosophy that programmers know what they are doing; it only requires that they state their intentions explicitly. Kernighan and Ritchie from The C Programming Language, 2 nd Edition

 You're already a better C programmer than you think you are  For selection, C supports:  if statements  switch statements  For repetition, C supports:  for loops  while loops  do while loops  Try to implement code the way you would in Java and see what happens…

 One significant gotcha is that C doesn't have a boolean type  Instead, it uses int for boolean purposes  0 (zero) is false  Anything non-zero is true if( 6 ) { //yep! } if( 0 ) { //nope! } if( 3 < 4 ) { //yep! } if( 6 ) { //yep! } if( 0 ) { //nope! } if( 3 < 4 ) { //yep! }

 Java is what is called a strongly-typed language  Types really mean something  C is much looser double a = 3.4; int b = 27; a = b; //legal in Java and C b = a; //illegal in Java, might //give a warning in C double a = 3.4; int b = 27; a = b; //legal in Java and C b = a; //illegal in Java, might //give a warning in C

 Another gotcha!  Can't declare a variable in the header of a for loop  Doesn't work:  You have to declare int i before the loop for( int i = 0; i < 100; i++ ) { printf("%d ", i); } for( int i = 0; i < 100; i++ ) { printf("%d ", i); }

 The C standard makes floating-point precision compiler dependent  Even so, it will usually work just like in Java  Just a reminder about the odd floating-point problems you can have: #include int main() { float a = 4.0 / 3.0; float b = a - 1; float c = b + b + b; float d = c - 1; printf("%e\n", d); } #include int main() { float a = 4.0 / 3.0; float b = a - 1; float c = b + b + b; float d = c - 1; printf("%e\n", d); }

 Math library  Data representation  More on types

 Read K&R Chapter 2  No class on Monday