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

C Language and Microsoft Access Introduction

This document provides an introduction to learning C programming and Microsoft Access 2003. It will cover 7 chapters of C programming concepts like input/output statements, decision constructs, and functions. It will also cover 7 chapters of Microsoft Access 2003, along with a class project in the first half. Some key topics discussed include the history and uses of C, different types of programming languages like low-level and high-level languages, and why C is still a useful language today for applications like operating systems, compilers, and embedded systems.

Uploaded by

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

C Language and Microsoft Access Introduction

This document provides an introduction to learning C programming and Microsoft Access 2003. It will cover 7 chapters of C programming concepts like input/output statements, decision constructs, and functions. It will also cover 7 chapters of Microsoft Access 2003, along with a class project in the first half. Some key topics discussed include the history and uses of C, different types of programming languages like low-level and high-level languages, and why C is still a useful language today for applications like operating systems, compilers, and embedded systems.

Uploaded by

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

Introduction to C

Programming and Microsoft


Access 2003

Introduction

Written by : Jawad Altaf (BS,CCNA,MCSA)


Research Associate Embedded System and Computer Architecture
Group, CIIT Lahore.
Course Contents

 “In second half of course you will be able to learn different


concepts of C language. C Language course will cover
total 7 chapters of C programming according to your
book”.
 “In first half you will cover Microsoft Office (Database
software)Access 2003 which includes 7 chapter along with
class project.”
Chapters for C language
 Getting started with C (intro)
 Elements of C
 Input /Output Statements
 Decision Constructs
 Conditional statements
 Loop Constructs
 Functions in C
 File Handling in C
What is Programming and their Concepts
 What is a programming language?
 Why are there so many programming languages?
 What are the types of programming languages?
 Does the world need new languages?
What is a Programming Languages
 A programming language is a set of rules that provides a way
of telling a computer what operations to perform.
 A programming language is a set of rules for communicating
an algorithm
 It provides a linguistic framework for describing
computations
What is a Programming Language
 English is a natural language. It has words, symbols and
grammatical rules.
 A programming language also has words, symbols and rules
of grammar.
 The grammatical rules are called syntax.
 Each programming language has a different set of syntax rules
Why Are There So Many Programming Languages

 Why does some people speak French?


 Programming languages have evolved over time as
better ways have been developed to design them.
– First programming languages were developed in the 1950s
– Since then thousands of languages have been developed
 Different programming languages are designed for
different types of programs.
Types of Computer Languages
 A computer languages are the languages by which a user
command a computer to work on the algorithm which a user
has written to get an output.
TWO TYPES OF COMPUTER LANGUAGES
 Low-level languages

 High-level languages
Low Level Language
 A low-level programming language is a programming
language that consists of numeric codes i.e 0 & 1. These
codes are easily understandable to computer but difficult to
human.. A lower level language is used in two generations of
computer.
• first generation

• second generation
First generation languages or 1GL
 Represent the very
early, primitive
computer languages that
consisted entirely of 1's
and 0's - the actual
language that the
computer understands
(machine language).
Second generation languages (2GL)
 Represent a step up from
the first generation
languages. Allow for the
use of symbolic names
instead of just numbers.
Second generation
languages are known as
assembly languages. Code
written in an assembly
language is converted into
machine language (1GL).
Low Level Languages
 Advantages  Disadvantages
• Computational Speed is • Development of a program
very fast. in machine language is very
• Directly understandable by time consuming.
computer. • Error correction is tedious
process.
HIGH LEVEL LANGUAGES

 High-level programming languages allow the specification of


a problem solution in terms closer to those used by human
beings. These languages were designed to make programming
far easier, less error-prone and to remove the programmer
from having to know the details of the internal structure of a
particular computer. This language is used in third generation.
Third generation languages (3GL)
 With the languages introduced
by the third generation of
computer programming, words
and commands (instead of just
symbols and numbers) were
being used. These languages
therefore, had syntax that was
much easier to understand.
Third generation languages are
known as "high level
languages" and include C,
C++, Java, and JavaScript,
among others.
Fourth Generation Languages
 A high level language (4GL) that requires fewer instructions
to accomplish a task than a third generation language.
 Used with databases
What is C?
 C
 A language written by Brian Kernighan and
Dennis Ritchie. This was to be the language that
UNIX was written in to become the first
"portable" language

In recent years C has been used as a general-


purpose language because of its popularity with
programmers.
C++
C++
 It is C language with additional features.
 Widely used for developing system and application software.
 Graphical user interfaces can be developed easily with visual
programming tools.
Visual Basic
 Visual Basic (VB) is the third-generation event-driven
programming language and integrated development
environment (IDE) from Microsoft for its COM programming
model. Visual Basic is relatively easy to learn and use.
JAVA
 JAVA
– An object-oriented language similar to C++ that eliminates
lots of C++’s problematic features
– Allows a web page developer to create programs for
applications, called applets that can be used through a
browser.
– Objective of JAVA developers is that it be machine,
platform and operating system independent
COBOL And FORTRAN
 FORTRAN
– Formula Translation.
– Developed at IBM in the mid-1950s.
– Designed for scientific and mathematical applications by scientists and
engineers.
 COBOL
– Common Business Oriented Language.
– Developed in 1959.
– Designed to be common to many different computers.
– Typically used for business applications.
BASIC
 BASIC
– Beginner’s All-purpose Symbolic Instruction Code.
– Developed at Dartmouth College in mid 1960s.
– Developed as a simple language for students to write programs
with which they could interact through terminals
Special Programming Languages
 Scripting Languages
– JavaScript and VBScript
– Php(preprocessor hypertext) and ASP(Active Server Page)
– Perl and Python
 Command Languages
– sh, csh, bash
 Text processing Languages
– LaTex, PostScript
Scripting Languages
 A high-level programming language
 Scripting languages, which can be embedded within HTML,
commonly are used to add functionality to a Web page, such as
different menu styles or graphic displays or to serve dynamic
advertisements.
 JAVA SCRIPT
 A scripting language developed by Netscape to enable Web
authors to design interactive sites.
 Javascript can interact with HTML source code, enabling Web
authors to spice up their sites with dynamic content.
 VB SCRIPT
 VBScript (Visual Basic Scripting Edition) developed by Microsoft that is
modeled on Visual Basic.
 It is designed as a "lightweight" language with a fast interpreter for use in a
wide variety of Microsoft environments.
PERL
 PERL
 Perl is a family of high-level, general-purpose, interpreted,
dynamic programming languages.
 "Practical Extraction and Reporting Language"
 The languages in this family include Perl 5 and Perl 6.
 Perl 5 is used for graphics programming, system
administration, network programming, finance,
bioinformatics, and other applications.
Python
 Python is widely used general-purpose, high-level
programming language.
 Its design philosophy emphasizes code readability, and its
syntax allows programmers to express concepts in fewer lines
of code than would be possible in languages such as C++ or
Java.
Why use C?
 Mainly because it produces code that runs nearly as fast
as code written in assembly language. Some examples
of the use of C might be:
– Operating Systems
– Language Compilers
– Assemblers
– Text Editors
– Print Spoolers
– Network Drivers
– Modern Programs
– Data Bases
– Language Interpreters
– Utilities

Mainly because of the portability that writing standard C programs can


offer
History
 In 1972 Dennis Ritchie at Bell Labs writes C and in
1978 the publication of The C Programming Language
by Kernighan & Ritchie caused a revolution in the
computing world

 In 1983, the American National Standards Institute


(ANSI) established a committee to provide a modern,
comprehensive definition of C. The resulting definition,
the ANSI standard, or "ANSI C", was completed late
1988.
Why C Still Useful?
 C provides:
 Efficiency, high performance and high quality s/ws
 flexibility and power
 many high-level and low-level operations  middle level
 Stability and small size code
 Provide functionality through rich set of function libraries
 Gateway for other professional languages like C  C++  Java

 C is used:
 System software Compilers, Editors, embedded systems
 data compression, graphics and computational geometry, utility
programs
 databases, operating systems, device drivers, system level
routines
 there are zillions of lines of C legacy code
 Also used in application programs
Compliers for C and C++ Language
 Following are the compliers for C, C++, C# languages

 Dev C++( Compatible with Windows,8,10,Linux)


 Turbo C ( Only compatible with Windows XP and Windows
7)
 Turbo C++ is a borland international implementation of
Complier for C language. It provides IDE (integrated
Development Environment) to create, edit, and Save programs in
C Text Editor.it can compile both programs of C and C++.
Turbo C++
 Shortcut Keys for Turbo C++ Complier
 ALT+F (opening a File)
 CTRL+S (Saving a file)
 CTRL+f9 (running the program)

Extension (.C for C programs and .CPP for C plus plus)


e.g.
Noname.CPP( default Name of C plusplus program extension)
Development with C
 Four stages
 Editing: Writing the source code by using some IDE or editor
 Preprocessing or libraries: Already available routines
 compiling: translates or converts source to object code for a specific
platform source code -> object code
 linking: resolves external references and produces the executable
module

 Portable programs will run on any machine but…..

 Note! Program correctness and robustness are most important


than program efficiency
History of C
 Hardware independent
 Programs portable to most computers
 Dialects of C
– Common C
– ANSI C
• ANSI/ ISO 9899: 1990
• Called American National Standards Institute ANSI C
 Case-sensitive
Chapter 8 basics
 Compiling the C program

 C compiler translates the source program into an object program with .obj
extension. To invoke this, use Shortcut key ALT+F9.
 The program written in any high level language, such as C, is called
source program.
 The compiler produces the object program from the source program.
Chapter 8 basics
 Linking the C program

 Linking is the process in which object file produced by the


compiler is linked to many other library files by the linker.
 The linker is the program that combines the object program
with additional object files that may be needed for the
program to execute.
Chapter 8 basics
 Executing the Program

 After successfully compiling and linking the program we


execute it. Shortcut key for execution is CTRL+F9. For
execution the program must be loaded into the memory which
is done by loader.
 Loader places the executable files in memory.
 To see program output press ALT+F5
Chapter 8 Basics
 Programming languages types:

 Unstructured programming languages


 The entire logic of the program is implemented in a single
module(function), which causes the program error prone , difficult
to understand, modify and debug.
 Structured programming languages
 The entire of the program divided into number of smaller modules,
where each module (piece of code) implements a different
functionality.
Chapter 8 Basics
 Preprocessor
– a system program that modifies the text of a C program
before it is compiled
 Preprocessor directives
– commands that provides instructions to the C preprocessor
• e.g. #include, #define
 Library
– a collection of useful functions and symbols that may be
accessed by a program
– each library has a standard header file
• e.g. stdio.h. math.h
Chapter 8 Basics
 #define
– using only data values that never change should be given
names
 Constant macro
– a name that is replaced by a particular constant value
#define KMS_PER_MILE 1.609

constant macro constant value


Syntax Displays for Preprocessor Directives(1/2)

 #include
– for defining identifiers from standard libraries
 Syntax:
– #include<standard header file>
 Examples:
– #include<stdio.h>
– #include<math.h>
Syntax Displays for Preprocessor Directives(1/2)

 #define
– for creating constant macros
 Syntax:
– #define NAME value
 Examples:
– #define MIL_PER_KM 0.62137
– #define PI 3.141593
– #define MAX_LENGTH 100
Input / Output Operations and Functions

 Input operation
– an instruction that copies data from an input device into
memory e.g. scanf
 Output operation
– an instruction that displays information stored in memory
e.g. printf
 Input/output function
– A C function that performs an input or output operation e.
g scanf, printf
 Function call
– Calling or activating a function
The printf Functon(1/3)

 Function argument
– enclosed in parentheses
– provide information needed by the function
 Format string
– a string of characters enclosed in quotes(“ ”)
– specify the form of the output line
 Print list
– the variables or expressions whose values are displayed
The printf Functon(2/3)

Function name

Format string
Syntax Display for Function Call
 Syntax:
– printf(format string, print list);
– printf(format string);
 Examples:
– printf(“I am %d years old, and my gpa is %f\n”, age,
gpa);
– printf(“Enter the object mass in grams> ”);
Basics of C Environment
 C systems consist of 3 parts
– Environment
– Language
– C Standard Library
 Development environment has 6 phases
– Edit
– Pre-processor
– Compile
– Link
– Load
– Execute
Basics of C Environment
Program edited in
Phase 1 Editor Disk Editor and stored
on disk
Preprocessor
Phase 2 Preprocessor Disk program processes
the code
Creates object code
Phase 3 Compiler Disk and stores on disk

Links object code


Phase 4 Linker Disk with libraries and
stores on disk
Basics of C Environment

Primary memory
Puts program in
Phase 5 Loader memory

Primary memory
Takes each instruction
Phase 6 CPU and executes it storing
new data values
Simple C Program

/* A first C Program*/

#include <stdio.h>

void main()

{
printf("Hello World \n"); EVERY PROGRAM IN C TERMINATES
WITH A SEMICOLON(;) IF NOT THE COMPILER WILL REPORT AN ERROR MESSAGE.

}
Simple C Program
 Line 1: #include <stdio.h>

 As part of compilation, the C compiler runs a program


called the C preprocessor. The preprocessor is able to
add and remove code from your source file.
 In this case, the directive #include tells the
preprocessor to include code from the file stdio.h.
 This file contains declarations for functions that the
program needs to use. A declaration for the printf
function is in this file.
Simple C Program
 Line 2: void main()

 This statement declares the main function.


 A C program can contain many functions but must
always have one main function.
 A function is a self-contained module of code that can
accomplish some task.
 Functions are examined later.
 The "void" specifies the return type of main. In this case,
nothing is returned to the operating system.
Simple C Program
 Line 3: {

 This opening bracket denotes the start of the program.


Simple C Program
 Line 4: printf("Hello World From About\n");

 Printf is a function from a standard C library that is used


to print strings to the standard output, normally your
screen.
 The compiler links code from these standard libraries to
the code you have written to produce the final
executable.
 The "\n" is a special format modifier that tells the printf
to put a line feed at the end of the line.
 If there were another printf in this program, its string
would print on the next line.
Simple C Program
 Line 5: }
 This closing bracket denotes the end of the program.
Common programming Errors

 Syntax Error
 Runtime Error
 Logical Error
 Syntax Error
 Occurs due to grammatical mistakes or grammar rules of C language.
 Causes
 Statement Terminator Missing, Variable without declaration,{ } brackets
missing.
Common Programming Error

 A runtime error occurs when program directs computer to


perform illegal operation.
 Causes:
 Dividing number by zero.
 Results:
 Computer stops executing program and displays a diagnostic
message.
Common Programming Error

 Logical error
 Its occurs when program follows a faulty algorithm.
 Causes:
 The compiler cannot detect logical error.
 Does not causes program to crash.

You might also like