Algorithms – Chapter 2

Ekluboko, K. (2018) Algorithme (Course material for Programmation : s’initier)


Getting started in C

Getting started with a program in the C programming language and the different phases of program development.

Here is a minimal program in C.

/* here you have to include libraries */ 

int main() 

{ / *start of the main block */ 

/* here you have to make the declarations */

 /* the instructions to be executed */ 

} /* end of the main block*/

Example:

/* The libraries */
#include <stdio.h>
int main()
{ /* Start of the main block */
/* The declarations */
int A;
int B;
A = 4;
B = 11;
/* The instructions */
printf("Hello\n\n");
printf(" A = %d \n B = %d\n ", A,B);
A = B- A;
B = B- A;
A = A+ B;
printf("RESULT\n---------------------------\n");
printf(" A = %d \n B = %d\n ", A,B);
} /* End of the main block*/

The different phases of program development

We write/edit the source code with a text editor (such as notepad, emacs ,vi, gedit, kate, etc…) and then the source code is processed by software called a COMPILER which creates a new file (point object). Link building is the establishment of calls between different source codes. It creates the executable file (.exe).

The entity that groups together the different source codes and all the other elements that enter the composition of the program is called a project.

You have all these tools grouped in an I.D.E. (Integrated Development Environment). For example: DEV C++, cygwin etc…

Below is a view of Code::Blocks.

Here is the result of the execution.


Leave a comment