[go: up one dir, main page]

0% found this document useful (0 votes)
19 views16 pages

ME 181 - 1st Lecture On C - Student

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

ME 181 - 1st Lecture On C - Student

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

ME 181

LECTURE # 01
COMPUTING BASICS

INTRODUCTION
Outline
 Basic Structure
 Executing of C program

 Simple Example
Facts about C
 C was invented to write an operating system called UNIX.
 C is a successor of B language which was introduced
around the early 1970s.
 The language was formalized in 1988 by the American
National Standard Institute (ANSI).
 The UNIX OS was totally written in C.
 Today C is the most widely used and popular System
Programming Language.
 Today's most popular Linux OS and RDBMS MySQL have
been written in C.
Why Use C?
C was initially used for system development work,
particularly the programs that make-up the
operating system. C was adopted as a system
development language. Some examples of the use
of C might be:
 Operating Systems
 Network Drivers
 Modern Programs
 Databases
 Utilities
Basic Structure of C Program
Documentation section
Link section
Definition section
Global declaration section
main () function section
{
Declaration part
Executable part
}
Subprogram section
Function 1
Function 2
Function 3
.
.
Function n
Basic Structure of C Program
Documentation Section
 This section consists of comment lines which include the
name of programmer, the author and other details like
time and date of writing the program. Documentation
section helps anyone to get an overview of the
program.
Link Section
 The link section consists of the header files of the
functions that are used in the program. It provides
instructions to the compiler to link functions from the
system library.
Basic Structure of C Program
Definition Section
 All the symbolic constants are written in definition

section.
Global Declaration Section
 The global variables that can be used anywhere in
the program are declared in global declaration
section. This section also declares the user defined
functions.
Basic Structure of C Program
main() Function Section
 It is necessary have one main() function section
in every C program. This section contains two
parts, declaration and executable part. The
declaration part declares all the variables that
are used in executable part. These two parts
must be written in between the opening and
closing braces. Each statement in the
declaration and executable part must end with
a semicolon (;).
Execution of C Program
Step 1 : Edit
 This is First Step i.e Creating and Editing
Program.
 First Write C Program using Text Editor.

 Save Program by using [.c] Extension.

 File Saved with [.c] extension is called “Source


Program“.
Execution of C Program
Step 2 : Compiling
 Compiling C Program : C Source code with [.c]
Extension is given as input to compiler and
compiler convert it into Equivalent Machine
Instruction.
 Compiler Checks for errors . If source code is
error-free then Code is converted into Object
File [.Obj ].
Execution of C Program
Step 3 : Checking Errors
 During Compilation, Compiler will check for
error, If compiler finds any error then it will
report it.
 User have to re-edit the program.

 After re-editing program , Compiler again

check for any error.


 If program is error-free then program is linked
with appropriate libraries.
Execution of C Program
Step 4 : Linking Libraries
 Program is linked with included header files.

 Program is linked with other libraries.

 This process is executed by Linker.


Execution of C Program
Step 5 : Error checking
 If run time error occurs then “Run-time” errors
are reported to user.
 Again programmer have to review
code and check for the solution.
Example of Simple C program
#include <stdio.h>
int main()
{
/* my first program in C */
printf("Hello, World! \n");
return 0;
}
Outcome of today’s class
Thank You

You might also like