Introduction to C Programming

Compiling Programs

To support a higher-level language, a special computer program must be developed that translates the statements of the program developed in the higher-level language into a form that the computer can understand—in other words, into the particular instructions of the computer. Such a program is known as a COMPILER

  • Editing - First write your program using text editor or Integrated Development Environment (IDE). Then you need to save your file by giving a suitable name with “.c” file extension. 
Ex :- MyFirstProgram.c

  • Compiling - is the conversion of human-readable source code in a programming language like C into machine code or intermediate code that can be executed by a computer.
  • Linking-After the program has been translated into object code, it is ready to be linked. The purpose of the linking phase is to get the program into a final form for execution on the computer.
  • Debugging - This is known as the debugging phase, during which an attempt is made to remove all the known problems or bugs from the program.

The process of compiling and linking a program is often called building.

IDE 

• The process of editing, compiling, running, and debugging programs is often managed by a single integrated application known as an Integrated Development Environment, or IDE for short. An IDE is a windows-based program that allows you to easily manage large software programs, edit files in windows, and compile, link, run, and debug your programs.

#include 

• Should be included at the beginning of just about every program you write. 

• It tells the compiler to include the standard input output header file stdio.h as part of the program.

int main (void)

• Informs the system that the name of the program is main, and that it returns an integer value, which is abbreviated “int.”

• Main is a special name that indicates precisely where the program is to begin execution.

• The keyword void that is enclosed in the parentheses specifies that the function main takes no arguments (that is, it is void of arguments).

{ } 

• Describe the boundary of the main function. This is done by enclosing all program statements of the routine within a pair of curly braces.

printf("Programming is Fun\n"); 

• The first statement specifies that a routine named printf is to be invoked or called.

\n 

 • Any characters to be printed after the newline character then appear on the next line of the display.

return 0 

• says to finish execution of main, and return to the system a status value of 0.

Comments

A comment statement is used in a program to document a program and to enhance its readability. comments serve to tell the reader of the program.

Comments are ignored by the compiler.

  • /* */ - This form of comment is often used when comments span several lines in the program.  
  • // - Any characters that follow these slashes up to the end of the line are ignored by the compiler.
/* This program demonstrate the application */ 
/* of new line character */ 
#include int main (void) 
/* Display text with new line character*/ 
printf ("Testing...\n..1\n...2\n....3\n"); 
return 0; 
}

It is a good idea to get into the habit of inserting comment statements into the program as the program is being written or typed in. A comment can not only help you read through the program, but it can also help point the way to the source of the logic mistake.

Comments