Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
31 views

Ch01-Introduction-To-Cprogramming Language

The document provides an introduction to the C programming language, including its history, uses, basic structure and syntax. It discusses setting up a C programming environment and compiling and running a simple C program.

Uploaded by

zidragroup
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Ch01-Introduction-To-Cprogramming Language

The document provides an introduction to the C programming language, including its history, uses, basic structure and syntax. It discusses setting up a C programming environment and compiling and running a simple C program.

Uploaded by

zidragroup
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 31

Lecturer : Liban Abdilatif Ahmed

Secure Web developer and research analyst


MS.c Information Security
University Putra Malaysia (UPM)
C Programming
Language
5th Edition
Learning Objectives
Upon completion of this material, you should be able to:

 Introduction to Computer Software


 Overview of Computer Programming Languages
 Overview of C programming Language
 The definition of C Programming Language
 History of C programming
 Why do we need to use C programming Language ?
 Getting Started with C programming
 C Program Structure
 Compile &Execute the Frist program in C environment
C programming Language 2
Introduction to Computer Software

 Software is the soul of the computer, which makes


hardware as usable and controls the hardware, software
often broken into two major categories: system software,
and application software .

 System software

 System software is responsible for controlling,


integrating, and managing the individual hardware
components of a computer system

C programming Language 3
Application software

 Application software, on the other hand, is used to


accomplish specific tasks other than just running the
computer system

C programming Language 4
Overview of Computer Programming
Languages
 A programming language is a standardized communication
technique for expressing
 instructions to a computer. Like human languages, each
language has its own syntax and grammar.
 Categories of Programming Languages
1. High-level Programming Languages
2. Low-level Assembly Language
3. Middle Level Languages

C programming Language 5
1. High-level Programming Languages

 A high-level programming language is a programming


language that is more user-friendly, to some extent
platform-independent, and abstract from low-level
computer processor operations such as memory accesses.
Eg:
 Microsoft’s .NET languages (e.g., Visual Basic, Visual C++
and Visual C#) and Java are among the most widely used
high-level programming languages.

C programming Language 6
Low-level Assembly Language

 low level language: which understandable by the operating


system
 3. Middle Level Languages:
is a programming language that combines high-level
languages elements with the functionality of assembly
language and has occasionally been referred to as a eg. C.

C programming Language 7
Early programming language

 COBOL – Common Business Oriented Language – used


primarily for business processing

 FORTRAN (Formula Translation) primarily perform


mathematical calculations

 Use of compiler as a translator

C programming Language 8
Later Programming Languages

 BASIC, Pascal, Prolog, C, Ada


 C++, Visual Basic,C#
 Python, Java,Perl,ruby,swift.

C programming Language 9
Overview of C programming Language

 C is a programming language developed at AT & T’s


Bell Laboratories of USA in 1972. It was designed and
written by a man named Dennis Ritchie.

 In the late seventies C began to replace the more


familiar languages of that time like PL/I, ALGOL, etc. No
one pushed C. It wasn’t made the ‘official’ Bell Labs
language.

C programming Language 10
Overview of C programming Language…
 In 1978, Brian Kernighan and Dennis Ritchie produced the
first publicly available description of C, now known as the
K&R standard.

 Possibly why C seems so popular is because it is reliable,


simple and easy to use. Moreover, in an industry where
newer languages, tools and technologies emerge and
vanish day in and day out, a language that has survived
for more than 3 decades has to be really good. .

C programming Language 11
Overview of C programming Language …
The UNIX operating system, the C compiler, and essentially
all UNIX applications programs have been written in C. The
C has now become a widely used professional language for
various reasons.
 Easy to learn
Structured language
 It produces efficient programs.
 It can handle low-level activities.
 It can be compiled on a variety of computer platforms.

C programming Language 12
The History of C programming
 C was invented to write an operating system called UNIX.
 C is a successor of B language, which was introduced around
1970.
 The language was formalized in 1988 by the American
National Standard Institute (ANSI).
 The UNIX OS was totally written in C by 1973.
 Today, C is the most widely used and popular System
Programming Language.
 Most of the state-of-the-art softwares have been implemented
using C.
 Today's most popular Linux OS and RBDMS MySQL have
been written in C.
C programming Language 13
Why to Use C program ?
 C was initially used for system development work, in
particular the programs that make up the operating
system.
 C was adopted as a system development language
because it produces code that runs nearly as fast as
code written in assembly language.
 Therefore, those are convincing reasons why one
should adopt C as the first and the very important step
in your quest for learning programming languages.
C programming Language 14
Why to Use C program ?...
Some examples of the use of C might be:
Operating Systems
Language Compilers
Assemblers
Text Editors
Print Spoolers
Network Drivers
Modern Programs
Databases, Language Interpreters and Utilities 15
Getting Started with C programming
 Communicating with a computer involves speaking the
language the computer understands, which immediately
rules out English as the language of communication with
computer.
 However, there is a close analogy between learning English
language and learning C language.
 Like the classical method of learning English using the
alphabets used in the language, Learning C is similar and
easier.
 Instead of straight-away learning how to write programs, we
must first know what alphabets, numbers and special
symbols are used in C
C programming Language 16
C Environment Setup
 This section describes how to set up your system
environment before you start doing your programming
using C language.

 Before you start doing programming using C programming


language, you need the following two softwares available
on your computer,

 (a) Text Editor

 (b) The C Compiler.


C programming Language 17
Compilers available for C are
 Turbo C
 Borland C
 Microsoft C
 DEV C++ can also be used.

C programming Language 18
The C Compiler
 The source code written in source file is the human readable
source for your program. It needs to be "compiled", to turn
into machine language so that your CPU can actually
execute the program as per instructions given.
 This C programming language compiler will be used to
compile your source code into final executable program.
 Al thought, there are several C compilers, in this course, we
will use one program called “DEV C++ “ which has combined
the text editor and C compiler

C programming Language 19
C Program Structure
 Before we study basic building blocks of the C programming
language, let us look a bare minimum C program structure
so that we can take it as a reference in upcoming chapters.

C programming Language 20
C Program Structure
A C program basically consists of the following parts:
Preprocessor Commands
Functions
Variables
Statements
& Expressions
Comments

C programming Language 21
C Hello World Example

Let us look various parts of the above program:


1.The first line of the program #include is a preprocessor
command, which tells a C compiler to include stdio.h file before
going to actual compilation.
2.The next line int main() is the main function where program
execution begins.
3.The next line /*...*/ will be ignored by the compiler and it has
been put to add additional comments in the program. So such
lines are called comments in the program.

C programming Language 22
C Hello World Example

4. The next line printf(...) is another function available in C which


causes the message "Hello, World!" to be displayed on the
screen.
5. The next line return 0; terminates main()function and returns
the value 0

C programming Language 23
Compile & Execute C Program
 Let’s look at how to save the source code in a file, and
how to compile and run it. Following are the simple steps:
 1. Open a DEV C+ + and add the above-mentioned
code.
 2. Save the file as hello.c

 3. To compile the C program, go to the menu bar and


click the compile tab .

C programming Language 24
Compile & Execute C Program …
 5. If there are no errors & warnings in your code, we t will
go to the next step which is to run the program.

 6. Now, Click Run tab at the menu bar.

 7. You will be able to see "Hello World" printed on the


screen

C programming Language 25
Compile & Execute C Program …

26
C Basic Syntax
 You have seen a basic structure of C program, so it will be
easy to understand other basic building blocks of the C
programming language.
 Tokens in C
 A C program consists of various tokens and a token is
either a keyword, an identifier, a constant, a string literal, or
a symbol. For example, the following C statement consists
of five tokens:

27
Semicolons ;
 In C program, the semicolon is a statement terminator.
That is, each individual statement must be ended with a
semicolon.
 It indicates the end of one logical entity.
 For example, following are two different statements:

28
Comments
 Comments are like helping text in your C program and they
are ignored by the compiler.
 They start with /* and terminates with the characters */ as
shown below:

 You cannot have comments within comments and they do


not occur within a string or character literals.

29
Summary

 Overview of C programming Language


 The definition of C Programming Language
 History of C programming
 Why do we need to use C programming Language ?
 Getting Started with C programming
 C Program Structure
 Compile &Execute the Frist program in C environment
 C Basic Syntex

C programming Language 30
Thank you
Q&A

You might also like