Professional Documents
Culture Documents
Programming Fundamentals: Introduction To Software Programming
Programming Fundamentals: Introduction To Software Programming
F U N D A M E N TA L S
G
INTRODUCTION TO SOFTWARE PROGRAMMIN
Programming Fundamentals
Introduction to Software
Sequence of instructions written using a Computer Programming Language to perform a
specified task by the computer. The categories of software.
System Software
Application Software
Utility software
System Software
Software required to run the hardware parts of the computer and other application software are
called system software.
Example : Operation System | Language Processor | Device Drivers
Application Software
Software that performs single task.
Example : Word processing | Spread sheet
Utility Software
Application software that assists system software to do tasks.
Example : Antivirus software | Backup tools
Introduction to Programming
Writing computer programs is called computer programming. Someone who can write computer
programs or in other words, someone who can do computer programming is called a Computer
Programmer.
DCSD/DSE/DNE 4
PAGE 01
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
Introduction to Language
These instructions can be written in various languages. Each programming languages have their
unique ways of organizing the commands which are called syntax. There are three types of
languages.
This language consists 0s and 1s and machine can understand. This language is machine
dependent.
This language consists of mnemonics which are words and symbols to define 0s and 1s. These
are machine dependent.
This language consists of statements which are like English. These are machine independent.
These are easy to create, read and understand.
The program written in High-level language called source code and the instructions in machine
readable format is called object code or machine code.
The system software that convert source code to machine code is called Language Processor.
There are three types.
Assembler : convert assembly level program to machine level program.
Interpreter : convert high level programs into machine level program line by line.
Compiler : convert high level programs into machine level program at one.
DCSD/DSE/DNE 5
PAGE 02
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
Introduction to C Language
C is a structured programming language developed by Dennis Ritchie in 1973 at Bell Laboratories.
C language was developed to write the UNIX operating system which is one of the most popular
network operating system in use today.
C History
C language has evolved from three different structured language ALGOL, BCPL and B Language.
In 1988, the language was formalized by American National Standard Institute (ANSI). In 1990,
a version of C language was approved by the International Standard Organization (ISO) and that
version of C is also referred to as C89. The version C11 of C language was introduced in 2011. It
is supported by all the standard C language compilers.
C Features
Machine independent
Mid-level programming language
Structures programming language
Rich library
Dynamic memory management
Use of Pointers
C compilers
CCS C Compiler
Turbo C
Minimalist GNU for Windows (MinGW)
Portable C Compiler
Clang C++
Digital Mars C++ Compiler
Intel C++
IBM C++
Visual C++ : Express Edition
Oracle C++
DCSD/DSE/DNE 6
PAGE 03
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
Structure of a C Program
#include <stdio.h>
int main()
{ printf("Hello C");
return 0;
}
Preprocessor
This initializes the environment of the program.
Syntax: #include<>
Header Files
This has definitions of the functions which can be used in any c program with
preprocessor # include.
Used to make the programs user friendly and easy to understand. These
comments are ignored by the compiler and are not executed.
Syntax 1: /* This is
C programming
*/
DCSD/DSE/DNE 7
PAGE 04
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
Body
Refers to the operations that are performed in the functions.
Output Statement
This is used to print a value.
Return Statement:
This defines the end of any C program. This is used to return of the values from a
function. This return statement and return value depend upon the return type of the
function. If the return type is void, then there will be no return statement. In any
other case, there will be a return statement and the return value will be of the type
of the specified return type.
White space
Used in C to describe blanks, tabs, newline characters and comments. Whitespace
separates one part of a statement from another and enables the compiler to identify
where one element in a statement, such as int, ends and the next element begins.
Example: int x;
DCSD/DSE/DNE 8
PAGE 05
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
How C Executes
Figure 1
After writing a source code compiler is used to compile the source code (in source file) and
convert it to an object code (machine code) in an object file. The machine code is
interpreted by CPU. The initial phrase of the compiling is called preprocessing.
The preprocessing is done by preprocessor which is called by the compiler. The tasks of
the preprocessor are;
Removing comments.
File inclusion.
Macro expansion.
The linker combines several object files and create a single executable file to execute the
program.
The loader loads program file into the memory for execution.
DCSD/DSE/DNE 9
PAGE 06
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
Figure 2
DCSD/DSE/DNE 10
PAGE 07
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
Tokens in C
TOKEN is the smallest unit in a 'C' program.
Figure 3
Keywords
Keywords are predefined, reserved words in C and each of which is associated with
specific features. There are total 32 keywords in C.
Table 1
Strings
A string is an array of characters ended with a null character (\0). Strings are always
enclosed with double quotes (“ “).
DCSD/DSE/DNE 11
PAGE 08
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T
P R O G R A M M I N G F U N DA M E N TA L S
Programming Fundamentals
Constants
A constant is a value assigned to the variable which will remain the same
throughout the program.
There are two ways of declaring constant:
o Using const keyword.
o Using #define pre-processor.
Table 2
Identifiers
These are user-defined names which consist of alphabets, number, underscore ‘_’
Example: number, name
Special Character
special meaning which cannot be used for another purpose.
Example: [], (), {}
Operators
Special symbol used to perform the functions.
Example: Arithmetic Operators, Relational Operators, Logical Operators
DCSD/DSE/DNE 12
PAGE 09
N AT I O N A L I N S T I T U T E O F B U S I N E S S M A N AG E M E N T