ET156 Introduction to C Programming

Similar documents
ET156 Introduction to C Programming

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

C: How to Program. Week /Mar/05

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

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

Introduction to Computing Lecture 01: Introduction to C

Programming and Data Structures

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

CMPE-013/L. Introduction to C Programming

Fundamentals of Programming

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

6.096 Introduction to C++ January (IAP) 2009

Chapter 2 - Introduction to C Programming

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

BLM2031 Structured Programming. Zeyneb KURT

Fundamental of Programming (C)

Variables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14

Chapter 1 & 2 Introduction to C Language

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

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

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

A Fast Review of C Essentials Part I

Introduction to the C Programming Language

C Language, Token, Keywords, Constant, variable

Procedures, Parameters, Values and Variables. Steven R. Bagley

!"#$% &'($) *+!$ 0!'" 0+'&"$.&0-2$ 10.+3&2),&/3+, %&&/3+, C,-"!.&/+"*0.&('1 :2 %*10% *%7)/ 30'&. 0% /4%./

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

Lecture 2: C Programming Basic

DEPARTMENT OF MATHS, MJ COLLEGE

Lecture 02 C FUNDAMENTALS

CC112 Structured Programming

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

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

Presented By : Gaurav Juneja

Programming in C++ 4. The lexical basis of C++

C Programming Review CSC 4320/6320


Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for

XSEDE Scholars Program Introduction to C Programming. John Lockman III June 7 th, 2012

Syntax and Variables

CMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Lab Session # 1 Introduction to C Language. ALQUDS University Department of Computer Engineering

CMSC 246 Systems Programming

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

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

COMP322 - Introduction to C++

COP 3275: Chapter 02. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA

Chapter 1: Introduction to Computers and Programming

C Program Structures

Preview from Notesale.co.uk Page 6 of 52

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Programming. C++ Basics

Data Types and Variables in C language

Lecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions

PROGRAMMAZIONE I A.A. 2018/2019

BSM540 Basics of C Language

SEQUENTIAL STRUCTURE. Erkut ERDEM Hacettepe University October 2010

BSM540 Basics of C Language

from Appendix B: Some C Essentials

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

Data types, variables, constants

Basic Elements of C. Staff Incharge: S.Sasirekha

ANSI C Programming Simple Programs

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

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

INTRODUCTION 1 AND REVIEW

VARIABLES AND CONSTANTS

Storage class and Scope:

#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0;

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu

C Overview Fall 2014 Jinkyu Jeong

Chapter 21: Introduction to C Programming Language

Tokens, Expressions and Control Structures

AMCAT Automata Coding Sample Questions And Answers

BBM 101 Introduc/on to Programming I Fall 2014, Lecture 3. Aykut Erdem, Erkut Erdem, Fuat Akal

DATA STRUCTURES AND ALGORITHMS

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

CS10001: Programming & Data Structures. Dept. of Computer Science & Engineering

CS Programming In C

CS 61C: Great Ideas in Computer Architecture Introduction to C

CSCI 2132 Software Development. Lecture 8: Introduction to C

Data Type Fall 2014 Jinkyu Jeong

A First Program - Greeting.cpp

Computers Programming Course 5. Iulian Năstac

Topic 6: A Quick Intro To C

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI 171 Chapter Outlines

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O)

Chapter 1 Introduction to Computers and Programming

C-Programming. Claude Fuhrer 5 août 2017

Review of the C Programming Language for Principles of Operating Systems

ANSI C Reserved Words

Informática Ingeniería en Electrónica y Automática Industrial

Transcription:

ET156 Introduction to C Programming Unit 1 INTRODUCTION TO C PROGRAMMING: THE C COMPILER, VARIABLES, MEMORY, INPUT, AND OUTPUT Instructor : Stan Kong Email : skong@itt tech.edutech.edu

Figure 1.3 Components of a Computer

Key Components of a Central Processing Unit (Processor) Processor Clock Instruction control unit Arithmetic and logic unit Registers

Main Memory Holds active programs and data. Contents: Bit: One binary digit 0 it or 1 Byte: Eight bits 1 character Word: A group of bytes Write is a destructive operation. Read is not a destructive operation. ROM Read only Memory. (non volatile). RAM Random Access Memory (volatile)

Input Input and Output The act of transferring data into memory from a peripheral p device. (for example : keyboard) Output The act of transferring data from memory to a peripheral device. (for example : Computer monitor) Input and Output Support the interaction between the user and Support the interaction between the user and the computer.

Secondary Storage Extension of main memory Fast, accurate, and inexpensive High capacity and nonvolatile Long term storage Contents must be transferred into main memory. Machine readable only People cannot read contents directly. Mdi Media Hard disk and floppy disk Magnetic tape CD ROM and DVD

Figure 1.5 Relationship between a Byte and a Bit

Figure 1.11 Entering, Translating, and Running a High Level Language Program

Figure 1.12 Flow of Information during Program Execution

Problem Solving

The Software Development Method 1. Specify the problem requirements. 2. Analyze the problem. 3. Design the algorithm to solve the problem. 4. Implement the algorithm. 5. Test and verify the completed program. 6. Maintain and updatetheprogram the program.

Variable Declarations Thememorycells used for storing a program s input data and its computational results are called variables. The variable declarations tell the C compiler the names of all variables and what kind of information will be stored in each variable. The general format for variable declaration is: Data type variable name or variable list; Example : int count; where int is data type of integer and count is the variable name.

C Reserved Words auto double include static break elif int struct case else long switch char enum main typedef const extern register union continue float return unsigned default for short void define goto signed volatile do if sizeof while

Hello World Example #include <stdio.h> /*Hello World Example */ int main(void) { printf( Hello World"); /* Comments can go here */ } return (0);

C Program Example #include <stdio.h> #define PI 3.14159 /*Your name*/ /*This programacceptsaccepts the radius ofa circle, calculates the area, andoutputs the radius and the area.*/ int main(void) ){ double radius; /*Stores the radius entered by the user*/ double cir; /* circumferre */ double area; /*Stores the area after the calculation*/ printf("enter the radius of the circle>"); scanf("%lf", &radius); area = PI * radius * radius; /*Calculates the area as PI X radius X radius and stores the results in area*/ printf("the area of a circle with a radius of %f is %f\n", radius, area); return (0); }

The Software Development Method 1. Specify the problem requirements. 2. Analyze the problem. 3. Design the algorithm to solve the problem. 4. Implement the algorithm. 5. Test and verify the completed program. 6. Maintain and updatetheprogram the program.

Algorithm to Program Include required libraries Define constants Declare variables Get the input Perform process to transform input tinto the output Display output t Refine the program

Preprocessor Directives Provide instructions to the preprocessor. Begin with # #include Used to load a library, such as a standard library #include <stdio.h> #define Used to define a constant macro #define PI 3.14159

Function main The point at which program execution begins Contains declarations and executable statements Standard format is: int main(void) { /*declarations*/ */ } /*executable statements*/ return (0);

scanf Function scanf("%lf", &variable name); Read the floating point number into the address of the memorycell referenced by the variable miles.

printf Function function arguments printf("that equals %f kilometers.\n", kms); function name format string print list That equals 16.090000 kilometers

Start Pelles C IDE/Create Project

Add win32 console project Enter project name for example : lab1 Select win32 console and check create new workspace.

Add source File to Project

Key in source code

Build /Execute Project

Output

Homework, Labs Homework Assignment due Week 2 Lab Assignment due to day. Email your homework assignment, lb labs to skong@itt tech.edu