0% found this document useful (0 votes)
11 views

Introduction To C Programming

Introduction.

Uploaded by

karthicksrujan16
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Introduction To C Programming

Introduction.

Uploaded by

karthicksrujan16
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

23ADT001 - C Programming

Module I
Topic – Introduction to C

23ADT001 - C PROGRAMMING
Introduction to C Programming
• The father of programming languages is ALGOL. It came in the year 1960.
With the help of ALGOL, the developer community learned about the concept
of structured programming language.
• In the year of 1967, a new programming language named BCPL was
introduced. BCPL stands for Basic Combined Programming Language. It is
specially used for writing system software.
• In 1972, a great computer scientist named Dennis Ritchie created the C
programming language. It includes all the features of B, BCPL, ALGOL, and
many more additional features too.

23ADT001 - C PROGRAMMING
Introduction to C Programming

• Nowadays, the C is used on a variety of operating systems


and hardware platforms.
• In the year 1990, C was approved by the International
Standards Organization(ISO). C language is also known
as ‘ANSI C’.

23ADT001 - C PROGRAMMING
History of C

23ADT001 - C PROGRAMMING
key features or characteristics of C language:

• C language is a general-purpose programming language.


• It is a middle level language, which means it combines the features
of high-level language with the functionality of an assembly language
• is a structured programming language ,procedural language
• is simple and easy to use
• has a vast collection of keywords, operators, built-in functions and
data types
• is portable and can be used in different environments

23ADT001 - C PROGRAMMING
key features or characteristics of C language:

• is a very flexible
• is fast
• is modular, i.e. can be divided into small modules
• is easily available
• is easy to debug, as it detects syntax errors quickly and
easily and displays the errors along with the line numbers
of the code and the error message

23ADT001 - C PROGRAMMING
C Basic commands Explanation

This is a preprocessor command that includes


#include <stdio.h> standard input output header file(stdio.h) from the C
library before compiling a C program

This is the main function from where execution of


int main() any C program begins.

{ This indicates the beginning of the main function.

whatever is given inside the command “/* */” in any


/
C program, won’t be considered for compilation and
*_some_comments_*/ execution.

printf(“Hello_World!
printf command prints the output onto the screen.
“);
This command waits for any character input from
getch(); keyboard.
This command terminates C program (main
return 0; function) and returns 0.

} This indicates the end of the main function.

23ADT001 - C PROGRAMMING
Compilers and Interpreters

• A program is a set of instructions performing a particular


task.
• The program can be written in assembly language as well as
high level language. This is source program.
• The source program is to be converted to the machine
language which is called object program.

23ADT001 - C PROGRAMMING
Compiler

Source Target
Program Compiler Program Debug on X

Compile on X

Target Output
Input
Program
Run on X

23ADT001 - C PROGRAMMING
Interpreter

Interpreter process

Source
program
Interpreter Output
Input

23ADT001 - C PROGRAMMING
Comparison b/w compiler and Interpreter
S.No Compiler Interpreter
.

Interpreter takes one


Compiler translates the entire
statement then translates it
1 program in one go and then
and executes it and then takes
executes it
another statement
Compiler generates the error Interpreter will stop the
2 report after the translation of translation after it gets the
entire program first error
Compiler takes a larger
3
amount of time in analyzing Interpreter takes lesser time
and processing the high level in the same process
language code

4
Overall execution time of code Overall execution time of a
is faster code is slower

23ADT001 - C PROGRAMMING
Compilation & Linking Process

23ADT001 - C PROGRAMMING
Execution Flow

23ADT001 - C PROGRAMMING
Execution Flow
Let's try to understand the flow of above program by the figure given below.
1) C program (source code) is sent to preprocessor first. The preprocessor is responsible
to convert preprocessor directives into their respective values. The preprocessor
generates an expanded source code.
2) Expanded source code is sent to compiler which compiles the code and converts it into
assembly code.
3) The assembly code is sent to assembler which assembles the code and converts it into
object code. Now a simple.obj file is generated.
4) The object code is sent to linker which links it to the library such as header files. Then it
is converted into executable code. A simple.exe file is generated.
5) The executable code is sent to loader which loads it into memory and then it is
executed. After execution, output is sent to console.
23ADT001 - C PROGRAMMING
Working with C

• Online Compiler links


• https://www.onlinegdb.com/online_c_compiler
• https://www.codechef.com/ide
• https://www.jdoodle.com/c-online-compiler/
• https://repl.it/languages/c
• https://www.programiz.com/c-programming/online-compil
er/
• https://www.tutorialspoint.com/compile_c_online.php
23ADT001 - C PROGRAMMING
Compiler

• Windows - OS
• Visual C++ 2008 Express Edition
• Turbo C++
• wxDev-C++
• Linux and Unix - OS
• GNU Gcc

23ADT001 - C PROGRAMMING
Turbo C++
• Open a new file from File > New in the
Turbo C++ IDE.
• Write a small program in the IDE.
• Now go to File > Save As and save the
program with the filename of your choice
(make sure extension of the filename is .c).
• Now go to compile and click on Compile.
And then Click on Run.
• You will see the output of your C program.

23ADT001 - C PROGRAMMING
References
• Ashok N.Kamthane, Amit.N.Kamthane, “Programming in C”, 3 rd
Edition, Pearson Education, 2015
• Ajay Mittal, “Programming in C-A Practical Approach”, 3 rd Edition,
Pearson Education, 2010.
• Yashavant P.Kanetkar, “Let Us C”, 16th Edition, BPB Publications,
2018.
• PradipDey, ManasGhosh, “Computer Fundamentals and
Programming in C”, 2nd Edition, Oxford University Press, 2013.

23ADT001 - C PROGRAMMING
23ADT001 - C PROGRAMMING

You might also like