Program Development Cycle 1.Edit program 2.Compile program - translates it from C to machine language 3. Run/execute your program. 4. If not satisfied,

Slides:



Advertisements
Similar presentations
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Programming In C++ Spring Semester 2013 Lecture 2 Programming In C++, Lecture 2.
C Programming Day 1 based upon Practical C Programming by Steve Oualline CS550 Operating Systems.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
1 ICS103 Programming in C Lecture 3: Introduction to C (2)
Structure of a C program
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
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?
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
Introduction to C Programming
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Introduction to C Language
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Ping Zhang 10/08/2010.  You can get data from the user (input) and display information to the user (output).  However, you must include the library.
Basic Input - Output. Output functions  printf() – is a library function that displays information on-screen. The statement can display a simple text.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
Programming I Introduction Introduction The only way to learn a new programming language is by writing programs in it. The first program to.
Input, Output, and Processing
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Scanf Reads in information from the keyboard Examples –scanf(“%d”, &number); –scanf(“%d%d”, &value1, &value2); WARNINGS! –Don’t forget the & (address of)
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
/* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
CECS 121 Test 1. Functions allow you to group program statements under one name C and C++ are case-sensitive so main(), MAIN(), and Main() are all different.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Computer programming Lecture#2 أ. إلهام باسندوه 1.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Minimal standard C program int main(void) { return 0 ; }
12/14/2016CS150 Introduction to Computer Science 1 Announcements  Website is up!   All lecture slides, assignments,
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
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.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Lecture2.
Numbers in ‘C’ Two general categories: Integers Floats
Basic concepts of C++ Presented by Prof. Satyajit De
Topics Designing a Program Input, Processing, and Output
CSC201: Computer Programming
INC 161 , CPE 100 Computer Programming
Chapter 2, Part I Introduction to C Programming
ICS103 Programming in C Lecture 3: Introduction to C (2)
Getting Started with C.
Lecture2.
OUTPUT STATEMENTS GC 201.
Chapter 2 - Introduction to C Programming
Introduction to CS Your First C Programs
Introduction to C++ Programming
Lecture3.
WEEK-2.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Introduction to C Programming
Instructor: Alexander Stoytchev
Introduction to C Programming
Presentation transcript:

Program Development Cycle 1.Edit program 2.Compile program - translates it from C to machine language 3. Run/execute your program. 4. If not satisfied, go back to #1.

/* Arup Guha My First C Program 8/23/07 COP 3223 Rocks! */ #include int main(void) { printf(“COP 3223 Rocks!\n”); return 0; } My First C Program

Purpose of Comments To tell the reader basic information about the program –Who wrote it –When they wrote it –What it does –Any other useful information about it Inside code, they inform the reader about the specific function of a group of statements.

#includes Tells the compiler that you may be using prewritten C functions for a particular library. We will always use stdio.h – it allows us to do standard input and output. When you call a function for a C library, it will look to all of the libraries you have included to find out HOW to run the function.

Function main The only code directly executed is the code inside of main The beginning and ending are delineated by { and }, respectively. Everything else is run in sequential order, as it is listed. Other functions (like printf) ONLY run if they are called from main, OR from another function called by main, etc.

printf Prewritten C function in stdio.h Prints out everything inside of “” exactly with these exceptions –A backslash and the character after it –A percent sign and the character after it Prints go in order, and the cursor starts where the last print ended.

Exceptions for prints Backslash – Escape Sequence –\n is a newline –\t is a tab –\\ is a backslash –\” is a double quote Percent Codes (Will be explained later) –%d (for integer variable) –%lf (for double variable) –%c (for character)

Variables Types we will commonly use –int –char –double How to Declare a Variable – ; Examples –int value; –char my_letter, your_letter; –double money;

Assignment Statement ( = ) ONE EQUAL SIGN, NOT TWO Syntax: = What it does: 1.Calculates the value of at that point in time. 2.Changes the value of to this NEW value.

/* Arup Guha My Second C Program 8/23/07 Computes the number of feet in a mile */ #include int main(void) { // Declare variables int feet_in_mile, yards_in_mile; int feet_in_yard; // Make calculation yards_in_mile = 1760; feet_in_yard = 3; feet_in_mile = yards_in_mile*feet_in_yard; // Output the result printf(“Mile = %d Feet.\n”, feet_in_mile); return 0; }

% code explanation If %d or a similar percent code is encountered inside “” of a printf, this is what happens –An expression must be specified after the end of the double quote, separated by a comma –Value of this expression is printed in the FORMAT of the type specified by the percent code. –Experiment to see what happens if you use the wrong percent code.