Structured Programming
Introduction
• Program:
   – A program is a set of sequenced instruction to cause a
     computer to perform particular operation or to solve the
     given problem
• Programming:
   – Process of developing such program is called programming
• Programmer:
   – Person who does programming is called programmer
• Programming Language:
   – The language that is used to develop the program is called
     programming language
   – “Programming languages are set of instruction used to
     write a program”
   – The language used to communicate with computer is
     known as programming language
   – program can be categorized based on how close to normal
     speech they are, and thus how far from the computer’s
     internal languages
          Generation of languages
•   Machine language or First Generation Language
•   Assembly language or Second Generation Language
•   Procedural language or Third Generation Language
•   Problem Oriented Language or Fourth Generation Language
•   Natural Language or Fifth Generation Language
                     ALGORITHM
• An algorithm is a process or set of rules to be followed in
  calculations or other problem-solving operations, especially
  by a computer
• Formally defined procedure for performing some calculation
• An effective procedure for solving a problem in a finite
  number of steps
• An algorithm gives the step by step description of how to
  arrive at a solution
       Characteristics of algorithm
• Accuracy
• Clarity
• Not even a single instruction must be repeated infinitely
• After the algorithm gets terminated, the desired result must
  be obtained
                    FLOWCHART
• A graphical or symbolic representation of a process
• Used to design and document complex processes to help the
  viewers to visualize the logic of the process
• Provides a better understanding of the process and find flaws,
  bottlenecks, and other less obvious features within it
• Usually drawn in the early stages of formulating computer
  solutions
• When designing a flowchart, each step in the process is
  depicted by a different symbol and is associated with a short
  description
                 C Programming
• The C Language is developed for creating system applications
  that directly interact with the hardware devices such as
  drivers, kernels, etc.
• C programming is considered as the base for other
  programming languages, that is why it is known as mother
  language.
• It can be defined by the following ways:
   – Mother language
   – System programming language
   – Procedure-oriented programming language
   – Structured programming language
   – Mid-level programming language
• C as a mother language
  – Most of the compilers, JVMs, Kernels, etc. are written in C
    language, and most of the programming languages follow
    C syntax, for example, C++, Java, C#, etc.
• C as a system programming language
  – A system programming language is used to create system
    software.
  – C language is a system programming language because
    it can be used to do low-level programming (for example
    driver and kernel
• C as a procedural language
  – A procedural language specifies a series of steps for the
    program to solve the problem.
  – A procedural language breaks the program into functions,
    data structures, etc.
• C as a structured programming language
  – Structure means to break a program into parts or
    blocks so that it may be easy to understand.
  – In the C language, we break the program into parts using
    functions. It makes the program easier to understand and
    modify.
• C as a mid-level programming language
  – C is considered as a middle-level language because
    it supports the feature of both low-level and high-level
    languages.
  – A Low-level language is specific to one machine, i.e.,
    machine dependent. It is machine dependent, fast to run.
    But it is not easy to understand.
  – A High-Level language is not specific to one machine, i.e.,
    machine independent. It is easy to understand.
                     History of C
• C programming language was developed in 1972 by Dennis
  Ritchie at bell laboratories of AT&T (American Telephone &
  Telegraph), located in the U.S.A.
• Dennis Ritchie is known as the founder of the c language.
• It was developed to overcome the problems of previous
  languages such as B, BCPL, etc.
• Initially, C language was developed to be used in UNIX
  operating system. It inherits many features of previous
  languages such as B and BCPL.
           Features of C Language
1. Small
   – C is a language of few words, containing only a handful of
     terms, called keywords, which serve as the base on which
     language’s functionality is built
2. Simple
   – C is a simple language in the sense that it provides
     a structured approach (to break the problem into
     parts), the rich set of library functions, data types, etc.
3. Machine Independent or Portable
   – Unlike assembly language, c programs can be executed on
     different machines with some machine specific changes.
     Therefore, C is a machine independent language.
4. Mid-level programming language
   – supports the feature of both low-level and high-level
     languages.
5. Structured programming language
   – C is a structured programming language in the sense
     that we can break the program into parts using functions.
     So, it is easy to understand and modify.
                  First C Program
   #include<stdio.h>
   void main()
   {
       printf("Hello World");
   }
• #include <stdio.h> includes the standard input output library
  functions. The printf() function is defined in stdio.h .
• main() The main() function is the entry point of every
  program in c language.
• printf() function is used to print data on the console.