C Language and Microsoft Access Introduction
C Language and Microsoft Access Introduction
Introduction
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
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
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
#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
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>
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
Logical error
Its occurs when program follows a faulty algorithm.
Causes:
The compiler cannot detect logical error.
Does not causes program to crash.