Engineering Computing I Chapter 1 – Part A A Tutorial Introduction.

Slides:



Advertisements
Similar presentations
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Advertisements

© 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5/e Starting Out with C++: Early Objects 5 th Edition Chapter 2 Introduction.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
Data types and variables
Chapter 2 Data Types, Declarations, and Displays
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 Chapter Two Introduction to the Programming Language C.
Lecture 5: Computer Languages. Programming Environments (IDE) COS120 Software Development Using C++ AUBG, COS dept.
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
Introduction to C Language
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
A First Program Using C#
Objectives You should be able to describe: Data Types
A First Book of ANSI C Fourth Edition
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Introduction to Computational Linguistics Programming I.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.
Chapter 2: Using Data.
Lecture 6: Computer Languages. Programming Environments (IDE) COS120 Software Development Using C++ AUBG, COS dept.
Lecture #5 Introduction to C++
ECE Application Programming Instructors: Dr. Michael Geiger & Nasibeh Nasiri Fall 2015 Lecture 2: Basic C program structure Data in C: Data types,
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Sixth.
Khalid Rasheed Shaikh Computer Programming Theory 1.
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.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Introduction to Computer Organization & Systems Topics: Types in C: floating point COMP C Part III.
1 Homework Done the reading? –K&R –Glass Chapters 1 and 2 Applied for cs240? (If not, keep at it!) Gotten a UNIX account? (If not, keep at it!)
C++ for Engineers and Scientists Second Edition
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
C Programming Lecture 3 : C Introduction 1 Lecture notes : courtesy of Woo Kyun and Chang Byung-Mo.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
 CSC 215 : Procedural Programming with C C Compilers.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Computer Science 210 Computer Organization
Computer Engineering 1nd Semester
Choice of Programming Language
Chapter 3: Understanding C# Language Fundamentals
Computer Science 210 Computer Organization
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Introduction to the C Language
Introduction to CS Your First C Programs
פרטים נוספים בסילבוס של הקורס
Introduction to Java, and DrJava part 1
Govt. Polytechnic,Dhangar
Introduction to C Topics Compilation Using the gcc Compiler
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
B. Ramamurthy University at Buffalo
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Introduction to Java, and DrJava
C Programming Getting started Variables Basic C operators Conditionals
Introduction to C Topics Compilation Using the gcc Compiler
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Unit 3: Variables in Java
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
EECE.2160 ECE Application Programming
Presentation transcript:

Engineering Computing I Chapter 1 – Part A A Tutorial Introduction

C is a general-purpose programming language C is not a ‘‘very high level’’ language C was originally designed for UNIX Spring 20112Chapter 1 - Part A

Getting Started Print the words: hello, world Spring 20113Chapter 1 - Part A

How to execute a program? (Step 1- Editing) 1.Create and edit a ‘C’ source file – Open a Command/Terminal Window – Use an “Text Editor” – Create the file “hello.c” – Enter the ‘C’ code – Save the file with a desirable path Spring 20114Chapter 1 - Part A

2.Compile the source file: – Compile the source file “hello.c” using a ‘C’ Compiler such as Microsoft ‘cc.exe’ compiler or GNU for your machine (Windows32, MAC or Linux) – Use the right compiler switches – The compiler produces an object file (binary machine code)  “hello.bin” How to execute a program? (Step2 - Compilation) Spring 20115Chapter 1 - Part A

3.Link the source file to other object files: – Link the object file “hello.bin” with the library files available in your machine using “link.exe” or similar programs. – Library files are collections of pre-compiled relocate-able basic functions or API’s. – The Linker produces an executable binary file (machine code)  “hello.exe” How to execute a program? (Step3 - Linking) Spring 20116Chapter 1 - Part A

Integrated Development Environment (IDE) In the IDE GUI environment: Enter and edit the source file Set Compiler and Linker switches Build  Compile & Link Run  Execute file in a command window Debug the file: – Watch Variables – Single Step – Go to a braekpoint Spring 20117Chapter 1 - Part A

Code Blocks Open source IDE Windows, MAC and Linux Versions Use GNU compiler/Linker Other IDEs: – Microsoft Visual C++ – Borland – WATCOM – etc. Spring 20118Chapter 1 - Part A

Code::Blocks IDE Text Editor Logs, Reports, etc. Multi-Tab Windows Pull-Down Menu Pull-Down Menu Spring 20119Chapter 1 - Part A

Your First C Program! Launch CodeBlocks in your machine Using Tool Bars: Carefully type in “Hello, World” program in a new C file. Save it as “hello.c” Build it. If any errors, correct and rebuild. Run The program. Repeat the above using icons. Spring Chapter 1 - Part A

Analysis of Program Functions Spring Chapter 1 - Part A

Variations to “hello, World” Spring Chapter 1 - Part A

Exercise ‘Formatted List’ Write a program using escape characters ‘\b’, ‘\t’, ‘\n’, etc. to generate the following print out: Number Name Age John 20 2 Adam 18 3 Michael 20 Save your program as: ‘FormattedList.c’ Spring Chapter 1 - Part A Separate using tabs

Exercise ‘Large Letters’ Write a program using escape characters ‘\b’, ‘\t’, ‘\n’, etc. to print out large letters (A, B, …): Save your program as: ‘LargeLetter.c’ Spring Chapter 1 - Part A * ** *** *

Solution toExercise ‘Large Letters’ Spring Chapter 1 - Part A

Variables and Arithmetic Expressions Spring Chapter 1 - Part A

Pseudo Code for Fahrenheit to Celsius Conversion Program: lower= 0; step = 20; upper = 300 fahr = lower; while fahr <= upper { celsius = (5/9)*(fahr-32) print far and celsius } Spring 2011Chapter 1 - Part A17 Variables and Arithmetic Expressions

Binary Arithmetic Operations OperationSymbol Addition+ Subtraction- Multiplication* Division/ Spring Chapter 1 - Part A

Fahrenheit to Celsius Spring Chapter 1 - Part A

1.Whole Numbers: 1, 2, 3, … 2.Whole Numbers plus 0: 0, 1, 2, 3, … 3.Whole Numbers with Positive or Negative Signs plus 0: …, -3, -2, -1, 0, 1, 2, 3 Tutorial on Numbers: Signed & Unsigned Integers Spring Chapter 1 - Part A Unsigned Integers

Tutorial on Numbers: Signed & Unsigned Integers Spring Chapter 1 - Part A 4-bit example , 1, 2, …, , ,…, -1, 0, 1, …, unsignedsigned

Tutorial on Numbers: Signed & Unsigned Integers - Size 1.char  8 bits 2.Small size int  short int 3.Medium Size  int 4.Large Size  long int Spring Chapter 1 - Part A

Tutorial on Numbers: Example: size on 32-bit machine char  8 bits short int  16 bits int  32bits long int  32 bits Spring Chapter 1 - Part A

Tutorial on Numbers: Examples on 32-bit machine UnsignedSigned Char int long Spring Chapter 1 - Part A

Exercise A ‘C’ Compiler is to be designed for a 4-bit microprocessor. Come up with relevant sizes for the following types: – char – int – long Find the signed and unsigned ranges for 64-bit integers Spring Chapter 1 - Part A

Floating Point The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is the most widely-used standard for floating-point computationIEEEfloating-point (−1) s × c × 10 q Example: – S=1 – c=12345 – q=-3 = Spring Chapter 1 - Part A

Float, double Name Common name BaseDigitsE minE max binary32 Single precision binary64 Double precision Spring Chapter 1 - Part A

Testing Different Sizes Using ‘sizeof()’ function, write a short program to determine the size of different types of variables on your machine. Spring Chapter 1 - Part A

Fahrenheit to Celsius More Accuracy Spring Chapter 1 - Part A

Width & Precision Spring Chapter 1 - Part A

Exercises Spring Chapter 1 - Part A

Solution toExercise 1.3 Spring 2011Chapter 1 - Part A32

Solution to Exercise 1.4 Spring 2011Chapter 1 - Part A33

The ‘For’ Statement InitializationConditionIncrement Body of Loop Spring Chapter 1 - Part A

Symbolic Constants Spring Chapter 1 - Part A