Unit 1 Notes
Unit 1 Notes
C PROGRAMMING
UNIT-01
Definition of C
C is a general-purpose, procedural programming language that provides low-level
access to a computer's system memory.
OR
Overview of C
C is a middle level, general purpose, compiler based and Procedure oriented programming
language (POP)
Features of C
Procedural Language
Fast and Efficient
Modularity
Statically Type
General-Purpose Language
Rich set of built-in Operators
Rich Library Set
Middle-Level Language
Portability
Easy to Extend
1) 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
3) 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.
4) 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 types a program they have to mention the type of variables used.
8) 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.
9) 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.
Structure of C
Documentation section
It is represented as:
//name of a program
Or
/*
Overview of the code
. */
Preprocessor section
The preprocessor section contains all the header files used in a program. It informs the
system to link the header files to the system libraries.
It is given by:
#include<stdio.h>
#include<conio.h>
The #include<stdio.h> consists of the contents of the standard input output files, which
contains the definition of stdin.
There are various header files available for different purposes. For example, # include
<math.h>. It is used for mathematic functions in a program.
Definition section
The define section comprises of different constants declared using the define keyword. It is
given by:
#define PI 3.142
Global declaration
The global section comprises of all the global declarations in the program. It is given by:
main function
main() is the first function to be executed by the computer. It is necessary for a code to
include the main(). It is like any other function available in the C library. Parenthesis () are
used for passing parameters (if any) to a function.
main()
We can also use int or main with the main (). The void main() specifies that the
program will not return any value. The int main() specifies that the program can return
integer type data.
int main()
Or
void main()
The user defined functions specified the functions specified as per the requirements of the
user. For example, color(), sum(), division(), etc.