You are on page 1of 16

Introduction to C

PREPARED BY: JOHN PAUL G. SANTOS

Outline

Introduction

Programming Steps

Components of Turbo C

Language Elements of C

Identifiers

Data Types

Variables an Constant Declaration

Operators

Arithmetic

Relational

Logical

What is C Language?

C is a general- purpose programming language which features


economy of expression, modern control flow and data structures
and a rich set of operations

Has been called as system programming language

A structured programming language

Programming Steps

Define the Problem

Design the Solution/Program

Code the Program

Test the Program

Document Error

Terms

Interpreter

Compiler

Reads the entire program and converts it into object code the form that
can be directly executed by the computer

Compile Time

Reads the source code of your program one line at a time and performs
the specific instructions contained in that line.

Refers to the events that occur during the compilation process

Object Code

A translation of the program source code in a form that can be directly


executed by the computer. It is also called the binary code and machine
code

Programming Process
Make/Edit the
Source Code

Source Code

Pre-processing
Compiler
(Compilation)

Object Code

Linker (Linking)

Executable Code

Close to a
code that can
be understood
by the
machine

Programming Process

Source Code

Run Time

Refers to the events that occur while the program is actually


executing

Library

The text of a program that a user can read; commonly thought as a


program

The collection of pre-written. Syntax errors are detected during


compiled time

Semantic Run

Time errors are detected during execution-time

Components of Turbo C

Editor

Used to create program code

Extended C Language

This version of C is significantly extended from "base home"


language of Ritchie's Specification.

The extension includes enhancement which make the Turbo C


compatible with the new proposed and ANSI Standard.

Compiler

Used to convert source code into machine code or binary code.

Components of Turbo C

Debugger

Run

Used for testing program and locating programming errors


Time environment is the capability for running programs within the
Turbo C System

User Interface

The various features of Turbo C are integrated into a single program


which allows you to smoothly proceed from source to code entry to
compilation to debugging to running without ever leaving the Turbo C
environment.

Language Elements of C

Identifiers
1.

Names that are used to reference variables, functions, labels


and various other user defined object; sequence of letters,
digits and special character-, which is called underscore

2.

Must consist only alphabetic characters, digits, or


underscores

3.

The first 63 characters of an identifier name are significant

4.

Examples: Sname, sname, lname, Lname

5.

An identifier may not be the same as a Turbo C keyword, and


it should not have the same name as function.

Data Types

int variables

A whole number consisting of an optional sign (+ or -) followed by a


sequence of digit. It cannot contain commas. Variables of this type
are often used for controlling loops and conditional statement
Type

Byte Size

Minimum
Value

Maximum
Value

short int

-32768

+32768

int

-2147483648

+2147483648

long int

-2147483648

+2147483648

unsigned int

16

65536

Data Types

float

double float

char

Variables and Constant


Declarations

Operators

Arithmetic
Command

Meaning

* (asterisk)

Multiplication

/ (slash)

Division

+ (plus)

Addition

- (minus)

Subtraction

- (unary minus)

Negation

% (modulus)

Modulus Division

++ (plus plus)

Increment Operator

- - (minus minus)

Decrement Operator

( ) parenthesis

Parentheis

Logical Operators

Command

Meaning

&&

And

||

Or

Not

Relational Operators
Command

Meaning

>

Greater Than

<

Less Than

>=

Greater Than or Equal to

<=

Less than or equal to

==

Equal to

!=

Not equal to