Pemrograman C Risanuri Hidayat. Why C  Compact, fast, and powerful  “Mid-level” Language  Standard for program development (wide acceptance)  It is.

Slides:



Advertisements
Similar presentations
Lecture 2 Introduction to C Programming
Advertisements

 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Principles of Programming Fundamental of C Programming Language and Basic Input/Output Function 1.
Introduction to C Programming CE Lecture 1 Introduction to C.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
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?
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction.
Chapter 2: Introduction to C++.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
The Pre-processor A unique feature of c language is the pre-processor. A program can use the tools provided by pre-processor to make his program easy to.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
A First Book of ANSI C Fourth Edition
Chapter 3 Getting Started with C++
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
C Programming Lecture 4 : Variables , Data Types
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Chapter 2: Java Fundamentals
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
C Hints and Tips The preprocessor and other fun toys.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
CC112 Structured Programming Lecture 2 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer.
Compiler Directives. The C Preprocessor u The C preprocessor (cpp) changes your source code based on instructions, or preprocessor directives, embedded.
C++ for Engineers and Scientists Second Edition
MAHENDRAN. Session Objectives Session Objectives  Discuss the Origin of C  Features of C  Characteristics of C  Current Uses of C  “C” Programming.
Chapter 2 C++ Syntax and Semantics, and the Program Development Process Topics – Programs Composed of Several Functions – Syntax Templates – Legal C++
Department of Electronic & Electrical Engineering Statements Blocks{} Semicolons ; Variables Names keywords Scope.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Introduction to ‘c’ language
Chapter 1.2 Introduction to C++ Programming
CSCE 206 Structured Programming in C
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Topic Pre-processor cout To output a message.
Chapter 2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Basic Elements of C++.
Chapter 13 - The Preprocessor
Objectives Identify the built-in data types in C++
Revision Lecture
C language IT-1 (Batch-A) Name: EnNo: Arshad Muthalif
Introduction to C Programming Language
' C ' PROGRAMMING SRM-MCA.
Basic Elements of C++ Chapter 2.
Statements, Comments & Simple Arithmetic
Introduction to Python
2.1 Parts of a C++ Program.
Govt. Polytechnic,Dhangar
Introduction to C++ Programming
Chapter 2: Introduction to C++.
C Programming Language
The C Language: Intro.
Chap 2. Identifiers, Keywords, and Types
Lexical Elements & Operators
Course Outcomes of Programming In C (PIC) (17212, C203):
Presentation transcript:

Pemrograman C Risanuri Hidayat

Why C  Compact, fast, and powerful  “Mid-level” Language  Standard for program development (wide acceptance)  It is everywhere! (portable)  Supports modular programming style  Useful for all applications  C is the native language of UNIX  Easy to interface with system devices/assembly routines  C is terse

Structure in C  C is case sensitive. All commands in C must be lowercase.  C has a free-form line structure. End of each statement must be marked with a semicolon. Multiple statements can be on the same line. White space is ignored. Statements can continue over many lines. #include main() { /* My first program */ printf("Hello Sayang…. \n"); } Listing 1. hello.c

Structure in C  The C program starting point is identified by the word main().  The two braces, { and }, signify the begin and end segments of the program.  #include is used to allow the printf statement to provide program output.  printf() is actually a function (procedure) in C that is used for printing variables and text. Where text appears in double quotes "", it is printed without modification, with some exceptions.

Structure in C  Keluaran layar: Hello Sayang….  Comments can be inserted into C programs by bracketing text with the /* and */ delimiters. /* My first program */  Header files contain definitions of functions and variables which can be incorporated into any C program by using the pre-processor #include statement.  To use any of the standard functions, the appropriate header file should be included. This is done at the beginning of the C source file. For example, to use the function printf() in a program, the line #include

Structure in C  #include  #include "mylib.h"  The use of angle brackets <> informs the compiler to search the compiler’s include directories for the specified file.  The use of the double quotes "" around the filename informs the compiler to start the search in the current directory for the specified file.

Structure in C  Identifiers in C must begin with a character or underscore, and may be followed by any combination of characters, underscores, or the digits 0-9. –summary exit_flag i –Jerry7 Number_of_moves _id

Structure in C  Keywords are reserved identifiers that have strict meaning to the C compiler. C only has 29 keywords. Example keywords are: –if, else, char, int, while  Names given to values that cannot be changed. Implemented with the –#define preprocessor directive. –#define N 3000 –#define FALSE 0 –#define PI –#define FIGURE "triangle"

Structure in C  Preprocessor statements begin with a # symbol, and are NOT terminated by a semicolon. Traditionally, preprocessor statements are listed at the beginning of the source file.  Preprocessor statements are handled by the compiler (or preprocessor) before the program is actually compiled. Once this substitution has taken place by the preprocessor, the program is then compiled.  In general, preprocessor constants are written in UPPERCASE. This acts as a form of internal documentation to enhance program readability and reuse.  In the program itself, values cannot be assigned to symbolic constants.

Example #include #define TAXRATE 0.10 main () { float balance; float tax; balance = 72.10; tax = balance * TAXRATE; printf("The tax on %.2f is %.2f\n",balance, tax); } The tax on is 7.21