0% found this document useful (0 votes)
27 views9 pages

Lesson 1: Introduction To C Programming

This document provides an introduction to the C programming language. It discusses that C was created in 1972 by Dennis Ritchie at AT&T Bell Labs, and was intended for system programming and developing operating systems like UNIX. C is a high-level language that is portable, efficient, and allows for direct hardware manipulation with features like pointers. The structure of a basic C program is explained, including header files, function declarations, the main function, and user-defined functions. Common preprocessor directives like file inclusion and macro definition are also outlined. Examples of simple C programs are provided.

Uploaded by

Larry Lim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views9 pages

Lesson 1: Introduction To C Programming

This document provides an introduction to the C programming language. It discusses that C was created in 1972 by Dennis Ritchie at AT&T Bell Labs, and was intended for system programming and developing operating systems like UNIX. C is a high-level language that is portable, efficient, and allows for direct hardware manipulation with features like pointers. The structure of a basic C program is explained, including header files, function declarations, the main function, and user-defined functions. Common preprocessor directives like file inclusion and macro definition are also outlined. Examples of simple C programs are provided.

Uploaded by

Larry Lim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 9

LESSON 1

Introduction to C Programming

Background
High-level
1972

- Dennis Ritchie at AT&T Lab


Intended for system programming
UNIX
C B (1970, Ken Thompson) BCPL (1967, Martin
Richards)

C++
Standard ANSI C
Institute)

(American National Standard

Why C ??

Portable
PCs to mainframes
Speed
Intended used for developing OS
Efficient, compact & direct manipulations
Directly manipulate bits, bytes, words, pointers
High-level features
Structure methodology
Flexible
Many types of programming purposes
Run-time error checking
Array-boundary check, argument-type compatibility

Structure of C Program

(1)

header file declaration


constant value declaration
function declaration
global variable declaration list and initialization

main ()
{
local variable declaration list and initialization
statement 1;
.
.
.
statement n;
return 0;
}
user defined function(s)

Structure of C program

(2)

Where user defined function structure:


function header
{
local data declaration list and initialization
statement 1;
.
.
.
statement n;
[return value;] /*optional*/
}

Preprocessor Directives
Always

begin with the pound sign #


Commands to C preprocessor
Two most common directives:

File Inclusion

Copy of the specified file to be inserted


#include <file.h> or #include file.h

Macro definition & substitution

Define macro subsequent occurrences of


the macro name are replaced by text
#define MAX_SIZE 100
#define sqr(x) ((x)*(x))

Simple C Program 1

Simple C Program 2

You might also like