Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Structured Programming Language

Course Title:510201
Total Marks:100
Incourse Marks:20
Written Marks:80
Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 1
Programming Language

 A programming language is a formal language comprising a set


of strings that produce various kinds of machine code output. Programming
languages are one kind of computer language, and are used in computer
programming to implement algorithms.

 A programming language is a set of commands, instructions, and


other syntax use to create a software .

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 2


Structured Programming

 C is called a structured programming language because to solve a large


problem, C programming language divides the problem into smaller structural
blocks each of which handles a particular responsibility. These structural
blocks are –
• Decision making blocks like if-else-elseif, switch-cases,
• Repetitive blocks like For-loop, While-loop, Do-while loop etc.
• subroutines/procedures - functions

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 3


Modular Programming

 C is called modular programming language because while solving large and


complex problem, C programming language divides the problem into smaller
modules called functions. Each of these functions has specific job. And entire
problem is solved by collecting such functions or smaller modules.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 4


Mid Level Language

 C is called middle-level language because it actually binds the gap between a


machine level language and high-level languages. A user can use c language to
do System Programming (for writing operating system) as well as Application
Programming (for generating menu driven customer billing system ).

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 5


High Level Language

 A high-level language (HLL) is a programming language such as FORTRAN,


or Pascal that enables a programmer to write programs that are more or less
independent of a particular type of computer. Such languages are considered
high-level because they are closer to human languages and further
from machine languages.
 In contrast, assembly languages are considered low-level because they are very
close to machine languages.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 6


Mid Level Language

 The middle-level language lies in between the low level and high-level
language. C language is the middle-level language. By using the C language,
the user is capable of doing the system programming for writing operating
system as well as application programming

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 7


Low Level Language

 A low-level language is a type of programming language that contains basic


instructions recognized by a computer. Unlike high-level languages used by
software developers, low-level code is often cryptic and not human-readable.
Two common types of low-level programming languages are assembly
language and machine language.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 8


Examples

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 9


Translator

 A translator takes a program written in source language as input and converts it


into a program in target language as output.
 Types of translator:
 Compiler
 Interpreter
 Assembler

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 10


Compiler

 The compiler is software that converts a program written in a high-level


language (Source Language) to low-level language (Object/Target/Machine
Language).

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 11


Interpreter

 An interpreter is a computer program, which converts each high-level program


statement into the machine code.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 12


KEY DIFFERENCE

• Compiler transforms code written in a high-level programming language into


the machine code, at once, before program runs, whereas an Interpreter
converts each high-level program statement, one by one, into the machine
code, during program run.
• Compiled code runs faster while interpreted code runs slower.
• Compiler displays all errors after compilation, on the other hand, the
Interpreter displays errors of each line one by one.
• Compiler is based on translation linking-loading model, whereas Interpreter is
based on Interpretation Method.
• Compiler takes an entire program whereas the Interpreter takes a single line of
code.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 13


Features Of C

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 14


Procedural Language: In a procedural language like C step by step
predefined instructions are carried out. C program may contain more
than one function to perform a particular task. New people to
programming will think that this is the only way a particular
programming language works. There are other programming
paradigms as well in the programming world. Most of the commonly
used paradigm is an object-oriented programming language.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 15


Fast and Efficient: Newer languages like java, python
offer more features than c programming language but due
to additional processing in these languages, their
performance rate gets down effectively. C programming
language as the been middle-level language provides
programmers access to direct manipulation with the
computer hardware but higher-level languages do not
allow this. That’s one of the reasons C language is
considered the first choice to start learning programming
languages. It’s fast because statically typed languages are
faster than dynamically typed languages.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 16


Modularity: The concept of storing C programming language
code in the form of libraries for further future uses is known as
modularity. This programming language van does very little on
its own most of its power is held by its libraries. C language has
its own library to solve common problems like in this we can
use a particular function by using a header file stored in its
library.
Statically Type: C programming language is a statically typed
language. Meaning the type of variable is checked at the time of
compilation but not at run time. This means each time a
programmer type a program they have to mention the type of
variables used.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 17


Rich set of built-in Operators: It is a diversified language with a
rich set of built-in operators which are used in writing complex or
simplified C programs.
Libraries with rich Functions: Robust libraries and functions in
C help even a beginner coder to code with ease.
Middle-Level Language: As it is a middle-level language so it has
the combined form of both capabilities of assembly language and
features of the high-level language.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 18


General Purpose Language: From system programming
to photo editing software, the C programming language is
used in various applications. Some of the common
applications where it’s used are as follows:
1. Operating systems: Windows, Linux,
iOS, Android, OXS
2. Databases: PostgreSQL, Oracle, MYSQL, MS
SQL Server etc.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 19


Portability: C language is lavishly portable as programs
that are written in C language can run and compile on any
system with either none or small changes.
Easy to Extend: Programs written in C language can be
extended means when a program is already written in it
then some more features and operations can be added to
it.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 20


C programming language has following importance:
1.C is robust language and has rich set of built-in functions, data types and operators which can be
used to write any complex program.
2.Program written in C are efficient due to availability of several data types and operators.
3.C has the capabilities of an assembly language (low level features) with the feature of high level
language so it is well suited for writing both system software and application software.
4.C is highly portable language i.e. code written in one machine can be moved to other which is very
important and powerful feature.
5.C supports low level features like bit level programming and direct access to memory using
pointer which is very useful for managing resource efficiently.
6.C has high level constructs and it is more user friendly as its syntaxes approaches to English like
language.

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 21


Different Forms Of main() Function

 Every C program has a primary (main) function that must be named main.
... The main function serves as the starting point for program execution. It
usually controls program execution by directing the calls to other functions
in the program.

❖ void main()
❖ int main()
❖ main ( )
❖ int main( void)
❖ void main (void)
Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 22
The #include Directive

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 23


#define Directive

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 24


Structure Of a C program

Fig: Basic Structure of a C program

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 25


Documentation Section
The documentation section is the part of the program where the programmer gives the details
associated with the program. He usually gives the name of the program, the details of the
author and other details like the time of coding and description. It gives anyone reading the
code the overview of the code.
Example
/*
* File Name: Helloworld.c
* Author: Manthan Naik
* date: 09/08/2019
* description: a program to display hello world
*/

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 26


Link Section
This part of the code is used to declare all the header files that will be used in the program.
This leads to the compiler being told to link the header files to the system libraries.

Example
#include<stdio.h>

Definition Section
In this section, we define different constants. The keyword define is used in this part
Example
#define PI=3.14

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 27


Sub Program Section
All the user-defined functions are defined in this section of the program.

int add(int a , int b)

{
return (a+b);
}

Md. Moklesur Rahman, Lecturer, Dept. Of CSE 22-Jan-22 28

You might also like