Introduction to C Programming

1,822 views 25 slides Dec 18, 2020
Slide 1
Slide 1 of 25
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25

About This Presentation

C Programming Basics Compiling and Linking Process in C


Slide Content

PROBLEM SOLVING AND PROGRAMMING USING C Presented By Mr.D.Anandhasilambarasan Assistant Professor Dept of CSE KIT – Kalaignarkarunanidhi Institute of Technology

UNIT- II C PROGRAMMING BASICS Introduction to ‘C’ programming: fundamentals, structure of a ‘C’ program, compilation and linking processes. Basic elements of ‘C’ programming: Constants, Variables, Data Types, Expressions, operators, Managing Input and Output operations. Control Statements : Decision Making and Branching, Looping statements. Problem Solving : solving simple scientific and statistical problems.

Introduction to ‘C’ programming C is a general-purpose programming language that is extremely popular, simple and flexible. It is machine-independent, structured programming language which is used extensively in various applications. C was the basic language to write everything from operating systems (Windows and many others) to complex programs like the Oracle database, Git, Python interpreter and more. It is said that 'C' is a god's programming language . One can say, C is a base for the programming. If you know 'C,' you can easily grasp the knowledge of the other programming languages that uses the concept of 'C'

History of C The base or father of programming languages is 'ALGOL.' It was first introduced in 1960 In 1967, a new computer programming language was announced called as 'BCPL' which stands for Basic Combined Programming Language. BCPL was designed and developed by Martin Richards , especially for writing system software in 1970 a new programming language called 'B' was introduced by Ken Thompson that contained multiple features of 'BCPL. In 1972, a great computer scientist Dennis Ritchie created a new programming language called 'C' at the Bell Laboratories. It was created from 'ALGOL', 'BCPL' and 'B' programming languages. 'C' programming language contains all the features of these languages

1. Operating System The first operating system to be developed using a high-level programming language was UNIX, which was designed in the C programming language. Microsoft Windows and various Android applications were scripted in C. 2 . Embedded System

3.GUI GUI stands for Graphical User Interface. Adobe Photoshop, one of the most popularly used photo editors since olden times, was created with the help of C. 4.New Programming Platforms

5.Google Google file system and Google chromium browser were developed using C/C ++. 6.Mozilla Firefox and Thunderbird Mozilla Firefox and Thunderbird were open-source email client projects, they were written in C/C++

7.Compiler Design One of the most popular uses of the C language was the creation of compilers. popular compilers were designed using C such as Bloodshed Dev-C, Clang C, MINGW, and Apple C 8.Gaming and Animations Most simple games are coded in C such as Tic-Tac-Toe, The Dino game, Snake game.

Features of C Language

Companies Using C  Almost all the companies that work on firmware, gaming, networking, graphics use C. Some of the companies that use C to write algorithms are :  

Advantages of C   Portable  – It is easy to install and operate and the result file is a .exe file that is easy to execute on any computer without any framework. Compiles faster  – C has a faster compiler that can compile 1000 lines of code in seconds and optimize the code to give speedy execution. User-defined functions  – C has many header files that define a lot of functions, making it easier for you to code. You can also create your functions; these are called user-defined functions (UDFs). C has a lower level of abstraction  – C is a very clear and descriptive language. You can, in a way, directly see into the machine without any conceptual hiding and so learning C first makes the concepts very clear for you to proceed.

How 'C' Works? C is a compiled language. A compiler is a special tool. A compiler is a computer program that converts our program code to machine understandable code(binary code ). After the compilation process, the linker will combine different object files and creates a single executable file to run the program.

Output Hello World

Structure of a ‘C’ program

# include < stdio.h > –  This command is a  preprocessor directive in C  that includes all standard input-output files before compiling any C program so as to make use of all those functions in our C program.   int main() –  This is the line from where the  execution of the program starts . The main() function starts the execution of any C program. { (Opening bracket) –  This indicates the  beginning of any function  in the program (Here it indicates the beginning of the main function). /* some comments */ –  Whatever is inside /*——-*/ are  not compiled and executed ; they are only written for user understanding or for making the program interactive by inserting a comment line. These are known as multiline comments. Single line comments are represented with the help of 2 forward slashes “//——”.

printf (“Hello World”) – The printf () command is included in the C stdio.h library, which helps to  display the message on the output screen . getch () –  This command helps to  hold the screen . return 0 – This command terminates the C program and returns a null value, that is, 0. } (Closing brackets)-   This indicates the  end of the function . (Here it indicates the end of the main function)

Compilation and linking processes in C There are three basic phases occurred when we execute any C program. Pre-processing Compiling Linking

Pre-processing Phase A C pre-processor is a program that accepts C code with preprocessing statements and produces a pure form of C code that contains no preprocessing statements (like #include).

Compilation Phase The C compiler accepts a preprocessed output file from the preprocessor and produces a special file called an object file. Object file contains machine code generated from the program

Linking Phase The link phase is implemented by the linker. The linker is a process that accepts as input object files and libraries to produce the final executable program.

Thank You…