C langauge, c-programming , c coding , coding, Study notes of Computer science

in depth knowledge on c- language this note makes you easy to learn c-coding

Typology: Study notes

2021/2022

Uploaded on 08/28/2025

unknown user
unknown user 🇮🇳

1 / 32

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download C langauge, c-programming , c coding , coding and more Study notes Computer science in PDF only on Docsity!

Volume – I

  • Introduction Topic Page – No’s
  • Programming Language & Types 3,4,5,
  • Developing Program
  • Software Development 8,
  • Algorithm 10,
  • Pseudo Code
  • Flow Chart
  • History of “C”
  • Characteristics 17,
  • Structure of “C” 19,20,21,
  • Creation , Linking, execution of Program 23,
  • Pre-processors 25,
  • Tokens 27,28,29,30,

3 M.Rakesh M.SC Programming Language A programming language is a formal language that specifies a set of instructions that can be used to produce various kinds of Output. Programming language generally consists of instructions for a computer. It can be used to create programs that implement specific algorithm. To write any program you should know computer programming language. Computer Programming Language A language which is used to communicate with a computer by the user. User can communicate with the computer by writing program (instructions). A program can be written using computer programming languages so there are different types of languages developed to communicate with the computer. The following are the types of computer Languages.  Low Level Language  Middle Level Language  High Level Language

Low Level Language / Machine Language

Low level language is the computer language that contains commands; this is only language which can understand by the computer. It is written using binary codes and this is machine dependent. Means programs which are written on one computer cannot be transferred to another computer. The low level language is also called as machine language. The CPU can directly understands the binary language instructions , it does not required any translators, because CPU directly starts executing the binary language instructions and takes very less memory and time to execute that instructions. Ex: - Machine Language / Binary Language which consists 0’s & 1’s , Assembly language

Advantages :

 Instructions will execute very fast  The programs which are written in machine language will execute very quickly & Efficiently by the CPU  The memory can be utilized in an efficient manner

Dis advantages :

 Machine language is very difficult to understand and read and remember by the users.  If any error occurs it is very difficult to rectify  The programs machine dependent means cannot be executed on different computers because computer will have different design or structure.

Middle Level Language / Assembly Language

Middle level language is a computer language in which the instructions are created using symbols, such as letters, digits and special characters. In Assembly language we use predefined words called as Mnemonics. In this binary code is replaced with mnemonics and operands such as 0’s, 1’s are replaced with letters a, b, c, d…….. , add, sub, mul…., But computer cannot understand mnemonics so we need

4 M.Rakesh M.SC to use a translator called ASSEMBLER. Means computer cannot understand Middle level language it needs to be translated into low level language to translate Assembler is used. Ex:- Assembly Language.

Advantages :

 Programs can be easily understand by the users  Easy to write assembly language programs  Takes very less time to write programs  Modifications can be done very easily  Errors can be removed quickly

Dis advantages :

 Translator is required to translate the programs  Execution of programs takes more time  It is alos machine dependent programs cannot execute on different computers

High Level Language

High level language is just like English language so instructions can be written very easily by the users but these instructions cannot understand by the computer. So these instructions need to be translated to low level language to translate compiler or interpreter is used. Ex:- C,C++ , Java ,C# , Python.

Advantages :

 It is very easy compared to machine & Assembly language  Programs can be developed in very less time  Modifications can be done very easily  Errors can be removed very easily  Programs are machine independent any program can execute in any computer with or without modifications.

Dis advantages :

 Translator is used to execute programs  Programs execute very slowly

Language Translators

It is a type of system software which is used to translate the user instructions which is written in one type of language into another type. Computer can understand only one language which is called as binary / machine / Low level language which contains only two digits 0’s & 1’s. To communicate with the computer a mechanism is required which translate the user instructions to machine language and machine language to user instructions. This type of conversion is done by a set of programs called translators.

6 M.Rakesh M.SC

Compiler:-

Compiler tanslates high-level language instructions into machine language  Compiler will scan complete program and then translate entire program into machine code  The compiler will show all the errors after scanning the complete program and debugging and testing is difficult in compiler  it translates whole program into machine code so its execution speed is high  It generates object code which is linked to system library  It requires more memory to store object code  The compiler based programming languages are C , C++ , Java

Interpreter:

An Interpreter is the translator which is used to translate high-level language instructions into machine language.  Interpreter will translate the program line by line or translate one statement at a time  If the statement contains an error then it is immediately stop the execution. it shows only one error at a time.  Testing and debugging is very easy , the interpreter stop the execution when the statements as errors and remaining statements will not execute.  It takes more time to execute the program and no object code is formed  It takes less memory to store the source code  The interpreter based programming languages are Pearl , python, ruby,etc

Developing Program

A person who designs and develops a program is called programmer  Defining Problem  Problem analysis  Algorithm Development  Coding  Testing & Debugging program  Documentation of the program Defining Problem :- It means explaining the requirement and understanding the data like what I/P given, what Output You want. Means specifies the kind of input, processing, and output required. Problem Analysis :- Analyses are made on the data like what are I / O operations, Result etc. what methods / functions are used. Data and operations are arranged systematically Algorithm Development:- It means step – by – step instructions are used to solve any problem. Here an algorithm is written for the problem. Coding:- As a programmer the next step is coding the generated algorithm using any programming languages like C, C++, java etc. Testing & Debugging :- Testing: - After coding the program it must be tested it on the computer to check requirements are solved or not. Debugging: - Debugging means detecting, locating, and correcting bugs (mistakes).which is done by running (executing) the program. Documentation:- Documentation is a written detailed description of the programming cycle and specific facts about the program. Typical program documentation include the origin and nature of the problem means a brief description of the program

Testing Testing starts once the coding is complete and the modules are released for testing. In this phase, the developed software is tested thoroughly if any defects are found they are assigned to developers to get them fixed. Retesting, regression testing is done until the point at which the software is as per the customer’s expectation. Testers refer SRS document to make sure that the software is as per the customer’s standard. Deployment Once the product is tested, it is deployed in the production environment or first UAT (User Acceptance testing) is done depending on the customer expectation. In the case of UAT, a replica (exact copy or model of software) of the production environment is created and the customer along with the developers does the testing. If the customer finds the application as expected, then sign off is provided by the customer to go live. Maintenance After the deployment of software on the production environment, maintenance of the product i.e. if any issue comes up and needs to be fixed or any enhancement is to be done is taken care by the developers.

The following any software model is used to develop any software

 Waterfall Model  V-Shaped Model  Prototype Model  Spiral Model  Iterative Increment Model  Big bang Model  Agile Model

Algorithms

Definition: It can be defined as step- by- step process is used to solve any problem. It is a sequence of statements which are used to perform any task (operation). It is effective method for solving a problem (program) by expressing as the sequence of steps. An Algorithm is typically referred as a set of instructions that can be executed by a computer to produce result (output). Algorithm is a well defined computation procedure that takes some set of values as Input and produces the result called as output.

Algorithm Properties

Algorithm contains 5 properties these properties are used to solve any problem the following are properties.  Input  Output  Finiteness  Definiteness  Effectiveness

Input :

Algorithm can receive one or more input quantities before algorithm process begins. Here algorithm input means data such a numbers, characters, text, images etc.

Output :

Algorithm will generate output after processing the input.

Finiteness:

An Algorithm should always terminate after finite number of steps , each of which may require one or more operations. In Algorithm the statements are executed repeatedly based on the condition, once the condition becomes false then Algorithm will stop repetition.

Definiteness:

It means specifying the sequence of operations for turning input into output. Means the details of each step must be given out (including how to handle errors).

Effectiveness:

It means the steps which are used to generate output must be effective and it must produce the correct output based on the input.

PSEUDO Code

It is the artificial language / Informal language / hypothetical language which is used to define Algorithms. It is not a programming language and it does not contain syntax rules so that the compiler does not process or execute pseudo code just it look like a program but not executed. It is used for develop the source code which is executed, it is helpful to the users to write source code easily. It is just like blue print for source code. Example- 1 :- Write a pseudo code to Add Two Numbers. Set a=10 , b= c=a+b Print c Output :- 30 Example- 2 :- Write a pseudo code to Multiply Three Numbers. Set a=5 , b=4 , c= d=abc Print d Output :- 40 Example- 3 :- Write a pseudo code to find largest of two numbers. Set a=5 , b= if(a>b) then Print a is largest else Print b is largest end if Output :- a is largest

Flow Chart

It is the diagrammatic representation of algorithm or it is a graphical representation of step- by – step procedure of a problem. In flow chart algorithm steps are represented by symbol it contains different types of symbols and each symbol contains the specific identity (Name, Meaning, operation). The following are the symbols which are commonly used in flow chart.

SYMBOL Meaning

Example- 2 :- Draw Flow Chart to find largest of two numbers.

Example- 3 :- Draw Flow Chart to print numbers 1-20.

History / Overview of “C”

The root of all modern languages is “ ALGOL “ means Algorithmic Language , it is introduced in the year 1960 by International Committee led by “ ALAN J. PERLIS “ ALGOL is the First Computer language used as Block Structure. This language was made popular language by “CORRADO BOHM” later in the year 1967 “Martin Richards” developed a language called BCPL(Basic Combined Programming Language), mainly used for writing System Software. In the year 1970 “Ken Thompson developed a language by using many features of BCPL and that language is called “B”, it is used to create versions of Unix operating system at “ Bell laboratories”. Here both BCPL & B Languages are system programming Languages. In the year 1972 “ Dennis Ritchie” at “Bell laboratories” developed a new Language from ALGOL , BCPL , B that language is “ C ” (Traditional C). So “C” was evolved from ALGOL , BCPL , B. “ C ” used many concepts from ALGOL , BCPL , B and added the new concepts in “C” such as data types and other powerful features. In the year 1983 the “American National Standard Institute” (ANSI) Appointed a technical committee to define a standards for “C” and the committee approved a new version of “C” in December 1989. which is known as “ ANSI C “. It was then approved by the ISO(International Standard organization) in 1990. This version of “C” is referred as C89 ( “ ANSI/ ISO C” )

“ C ” DEVELOPMENT STAGES

 “ C ” is a structured oriented programming language

 It is a high-level language that was originally developed by “Dennis Ritchie” at

“Bell Laboratories” in the year 1972

 It was developed for implementing Unix operating system

 It is a robust (Strong) language due to consisting of operators, Built-in-

functions that are used for writing complex programs.

 It is an efficient programming language that includes large variety of data types

and more powerful operators.

 it is many times faster than BASIC for example a program to increment a

variable form 1-1500 it takes about one second in “C” , while it takes more

than 50 seconds in BASIC.

 There are 32 keywords and several standards functions are available which can

be used for developing programs

 It is highly portable that means “ C” programs written for one computer can be

executed on another computer with some or no modifications.

 C- language is well suited for structured programming because this structure

makes program debugging, testing and maintenance easier.

 Programs in the “C” language are executed top- bottom means it is top-down

structure.

 “C” is the most widely used and popular system programming language

 It supports the memory management which is also called as Dynamic Memory

Allocation means we can free the allocated memory at any time.

 .The compilation and Execution time of C-language is fast.

 “C” Language is Extensible because it can easily adopt new features.

 “C – Language “is also used to do Low – Level programming it is used to develop system

applications such as Kernel , System Drivers etc. It also supports the features of High-level language. That is why it is also known as Mid-Level language.

Structure of “C”

Structure of C – program is defined by set of rules called as protocols. These protocols must be followed by the programmer while writing the C-program. The general basic structure of C – program contains the following.  Documentation section  Link Section  Definition section  Global declaration  Main function  User defined / sub program section

Definition Section