0% found this document useful (0 votes)
5 views5 pages

C_Introduction

C programming, developed in 1972 by Dennis M. Ritchie, is a general-purpose, procedural, and structured programming language known as the 'mother language' for its foundational role in many other languages. It offers advantages such as efficiency, portability, and close hardware interaction, but has drawbacks like manual memory management and lack of object-oriented features. The document also outlines the compilation process, header files, macros, constants, and the importance of comments in enhancing code readability.

Uploaded by

emon.950940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

C_Introduction

C programming, developed in 1972 by Dennis M. Ritchie, is a general-purpose, procedural, and structured programming language known as the 'mother language' for its foundational role in many other languages. It offers advantages such as efficiency, portability, and close hardware interaction, but has drawbacks like manual memory management and lack of object-oriented features. The document also outlines the compilation process, header files, macros, constants, and the importance of comments in enhancing code readability.

Uploaded by

emon.950940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Course Code: CSE-121 Course Title: Structured Programming Language

Introduction
➢ C programming is a general-purpose, procedural, imperative computer programming
language.
➢ Developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories
• To develop the UNIX operating system
• 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 is also known as
• 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.

• System programming language - it can be used to do low-level programming (for


example driver and kernel). It is generally used to create hardware devices, OS,
drivers, kernels, etc. For example, Linux kernel is written in C.

• Procedure-oriented programming language - A procedure is known as a function,


method, routine, subroutine, etc. 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.

• Structured programming language - A structured programming language is a subset


of the procedural 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.

• Mid-level programming language - It supports the feature of both low-level and high-
level languages. C language program is converted into assembly code, it supports
pointer arithmetic (low-level), but it is machine independent (a feature of high-level).

❖ 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.
Course Code: CSE-121 Course Title: Structured Programming Language

➢ Advantages of C Language
• Efficiency and speed
• Portable
• Close to Hardware
• Standard Libraries
• Structured Programming
• Procedural Language
• Versatility

➢ Drawbacks of C Language
• Manual Memory Management
• No Object−Oriented Feature
• No Garbage Collection
• No Exception Handling

➢ Applications of C Language
• System Programming
• Embedded Systems
• Compiler and Interpreters
• Database Systems
• Networking Software
• Game Development
• Text Editor and IDEs
• Scientific and Mathematical Applications

➢ Example
#include <stdio.h>

int main()
{
printf("Hello, World!\n");

return 0;
}
Course Code: CSE-121 Course Title: Structured Programming Language

➢ Include Header Files


Contain declarations of functions, constants, and macros that can be used in one or more
source code files.
• stdio.h − Provides input and output functions like printf and scanf.
• stdlib.h − Contains functions involving memory allocation, rand function, and
other utility functions.
• math.h − Includes mathematical functions like sqrt, sin, cos, etc.
• string.h − Includes functions for manipulating strings, such as strcpy, strlen, etc.
• stdbool.h − Defines the boolean data type and values true and false.
• time.h − Contains functions for working with date and time.

➢ Macros and Constants


Define any macros or constants that will be used throughout the program. Macros and
constants are optional.

Example:
#include <stdio.h>
#define PI 3.14159
int main() {
float radius = 5.0;
float area = PI * radius * radius;

printf("Area of the circle: %f\n", area);


return 0;
}

➢ Compilation process in C
• The compilation is a process of converting the source code into object code. It is
done with the help of the compiler.
• The compiler checks the source code for the syntactical or structural errors, and if
the source code is error-free, then it generates the object code.
• The c compilation process converts the source code taken as input into the object
code or machine code. The compilation process can be divided into four steps, i.e.,
Pre-processing, Compiling, Assembling, and Linking.
• The preprocessor takes the source code as an input, and it removes all the
comments from the source code. The preprocessor takes the preprocessor
directive and interprets it. For example, if <stdio.h>, the directive is available in
the program, then the preprocessor interprets the directive and replace this
directive with the content of the 'stdio.h' file.
Course Code: CSE-121 Course Title: Structured Programming Language

Preprocessor
The source code is the code which is written in a text editor and the source code file is given an
extension ".c". This source code is first passed to the preprocessor, and then the preprocessor
expands this code. After expanding the code, the expanded code is passed to the compiler.
Compiler
The code which is expanded by the preprocessor is passed to the compiler. The compiler converts
this code into assembly code. Or we can say that the C compiler converts the pre-processed code
into assembly code.
Assembler
The assembly code is converted into object code by using an assembler. The name of the object
file generated by the assembler is the same as the source file. The extension of the object file in
DOS is '.obj,' and in UNIX, the extension is 'o'. If the name of the source file is 'hello.c', then the
name of the object file would be 'hello.obj'.
Linker
Mainly, all the programs written in C use library functions. These library functions are pre-
compiled, and the object code of these library files is stored with '.lib' (or '.a') extension. The
main working of the linker is to combine the object code of library files with the object code of
our program.
Course Code: CSE-121 Course Title: Structured Programming Language

➢ Comments in C
• Using comments in a C program increases the readability of the code.
• In C, there are two types of comments –
i. Single-line comments
ii. Multi-line comments
• Syntax of Single-line C comment: //comment text
• Multi-line Comment in C:
/* The comment starts here
Line 1
Line 2
…..
…..
Comment ends here*/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy