Presentation is loading. Please wait.

Presentation is loading. Please wait.

Writing, Compiling and Running a C program

Similar presentations


Presentation on theme: "Writing, Compiling and Running a C program"— Presentation transcript:

1 Writing, Compiling and Running a C program
PROGRAMMING IN C Lecture-2 Writing, Compiling and Running a C program

2 WRITING SOURCE CODE Source Code is actually the set of instructions which a programmer writes in an editor. These instructions are written according to the syntactical rules of C language. Any text editor such as notepad, word pad, DOS text editor etc can be used for writing source code. But using a standard editor such as DevC++, codeblock, netbeans etc is recommended. We shall use the DevC++ editor throughout the course.

3 SOURCE CODE WRITTEN IN NOTEPAD

4 SOURCE CODE WRITTEN IN DEV-C++

5 SAVING THE COURCE CODE The source code file must be saved with the file extension .c . For example, test.c or merit.c Since we are using C++ compiler, therefore, we shall save our source files with extension .cpp In our example, the source file name is:- examplecode.cpp

6 COMPILING THE SOURCE CODE
A source code is written in alphanumeric form which is the computer cannot understand. It must be converted into binary form or machine language. The process of translating a high-level language program into machine language is called compilation. When compilation is completed, a new file is created in C called OBJ file or object file. Its file extension is .obj and is created by the compiler. Compilation is performed by applying the compile command from the Menu bar or by using the F9 function key in Dev-C++.

7 COMPILATION

8 OBJECT FILE CREATED In our example, the object file will be:- Examplecode.obj

9 EXECUTING THE C PROGRAM
After compilation, the linker attaches important information with the compiled code and prepares it for execution by the processor. The ready code is called executable code and a new file is created which has the file extension .exe In our example, the executable file is:- Examplecode.exe The run command performs the execution or the function key F10 can be used in Dev-C++. When the program is executed, we get the output.

10 EXECUTION

11 THANK YOU


Download ppt "Writing, Compiling and Running a C program"

Similar presentations


Ads by Google