0% ont trouvé ce document utile (0 vote)
44 vues6 pages

Introduction à Dev-C++ et C Programming

Transféré par

Yasmine Mahdoui
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
44 vues6 pages

Introduction à Dev-C++ et C Programming

Transféré par

Yasmine Mahdoui
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Issat Sousse AU : 2022/2023

Département informatique

TP N° 1 : Découverte de l’environnement C
Objectifs :

 Prise en main de l'environnement de programmation Dev-C++


 La découverte de quelques fonctions de base en langage C.

 Lancement du Dev-C++

Dev-C++ est est un environnement de développement intégré (IDE) permettant de programmer


en C et en C++ pour les systèmes d'exploitation Windows.

a) Lancer un nouveau projet : File->New->Project

Etape1

Etape2

Nommer votre projet :


TP1LangageC_NomPrenom Nom du projet

1/6
Issat Sousse AU : 2022/2023
Département informatique

Emplacement du Etape3
projet

Etape4

Vérifier sur le bureau y’a-t-il un dossier nommé TP1LangageC_NomPrenom?


Le projet créé contient combien de fichier ?

2/6
Issat Sousse AU : 2022/2023
Département informatique

b) L’interface générale se présente sous cette forme :

L’interface de développement de Dev-C++, en dehors de ses menus et barres


d’outils, possède trois zones :

1. Projets: Regroupe l’ensemble des projets et ses différentes ressources.

2. Affichage : zone d’affichage et d’édition des programmes.

3. Output : fenêtre d’affichage des résultats de la compilation, des


erreurs,…………

c) Premier programme C

1- Créer un nouveau fichier : -> Bouton droit sur le projet -> New File

3/6
Issat Sousse AU : 2022/2023
Département informatique

2-Renommer le nouveau fichier sous PremierProgramme.c

3-Dans ce fichier, écrire le programme suivant :

#include <stdio.h> Directives de préprocesseur

int main( ) Fonction principale

/* Debut du mon premier programme

en langage C */ Instruction(s)

printf("Mon premier programme en C!!\n");

return 0;

//Fin de mon programme C

4- Sauvegarder le fichier: menu File->Save

5- La compilation :

Compiler ce programme à partir de menu Execute -> compile (F9)

4/6
Issat Sousse AU : 2022/2023
Département informatique

6- Exécution :

Exécuter le programme avec Execute -> Run (F10)

7- Supprimer le point-virgule après l’instruction:

printf("Mon premier programme en C!!\n");

Compiler et commenter.

8- Supprimer les deux lignes suivantes :

/* Debut du mon premier programme

en langage C */

Compiler et commenter.

9- Supprimer la ligne suivante : // Fin du mon programme C

Compiler et commenter.

NB : Un commentaire en C peut être sur une ligne ou sur plusieurs.

5/6
Issat Sousse AU : 2022/2023
Département informatique

Exercice 1: Ecrire un message ( printf )

Créez dans le même projet un nouveau fichier nommé Ex1 et tapez le


programme suivant :

1. Compiler le programme ci-dessus. Lisez bien les messages d'erreurs puis corriger le
programme.

2. Modifier le programme pour qu'il affiche ce que suit:

3. Ajouter la ligne suivante juste après l’instruction printf("\n\n");

printf("\n Nous somme le \12.10.2030\!!!\n");

4. Remplacer Flen par votre nom_prenom, et modifier ce programme pour qu’il


affiche:

**************************************************************
* BIENVENUE DANS LE MONDE DE PROGRAMMATION *

* Programme écrit par "Flen" *

* Etudiant(e) ISSAT Sousse, A.U 2022/2023 *

***************************************************************

6/6

Common questions

Alimenté par l’IA

The purpose of using the Dev-C++ environment in the programming course is to provide a comprehensive Integrated Development Environment (IDE) that facilitates programming in C and C++ specifically for Windows operating systems. It helps students to familiarize themselves with basic functions of the C language and manage their projects effectively through its interface, which offers separate zones for projects, display, and output .

The debugging strategy involves reading the compiler's error messages carefully, analyzing the code line where the error occurs, and making necessary corrections. For instance, when compilation errors arise from syntax issues like missing semicolons or incorrect comment usage, students are encouraged to correct those and recompile for verification, ensuring the program runs without errors .

In C programming, single-line comments start with '//', while multi-line comments are enclosed within '/*...*/'. These comments are employed to annotate code for clarity, elucidating the function or purpose of specific code sections or providing insights into complex logic without affecting the program's execution, as demonstrated in the exercise .

A basic C program, as outlined, includes the use of preprocessor directives such as #include <stdio.h>, a main function serving as the entry point of the program, and the printf function to output text. Comments are used to explain sections of the code, which the compiler ignores. The program structure also demonstrates basic compilation and execution steps .

The exercise promotes personalized learning by allowing students to modify code with personalized elements, such as replacing placeholder names with their own, and encouraging exploration of different outputs. This approach helps in reinforcing the understanding of code functionality and fosters a sense of ownership over the learning process by engaging students actively in the development environment .

Commenting on code significantly influences debugging and code maintenance by providing a human-readable explanation of code logic and functionality. This practice aids other developers in understanding the purpose of complex code sections and assists in troubleshooting by making code behavior transparent. Well-documented code enhances maintainability and reduces the time spent on deciphering logic, as highlighted with both single and multi-line comments in the exercise .

To configure a new project in Dev-C++, you should start by selecting File->New->Project, then name your project following the format 'TP1LangageC_NomPrenom'. Ensure a corresponding directory appears on the desktop, which indicates the project setup. The interface allows organizing resources within the project using the Projets, Affichage, and Output zones .

Naming conventions for files and projects in Dev-C++ are important as they help in organizing projects systematically and ensure that each project and file are easily identifiable. Adhering to specified naming formats like 'TP1LangageC_NomPrenom' helps maintain consistency across projects and clarifies the project purpose and ownership, facilitating smooth collaboration and individual tracking .

The Output window in Dev-C++ plays a crucial role by displaying the results of program compilations, including any error messages. This allows students and developers to immediately see feedback from the compilation process, which aids in debugging and ensures that any syntax or logical errors can be quickly identified and resolved .

Removing a semicolon from a statement such as 'printf("Mon premier programme en C!!\n")' results in a syntax error because the C language requires semicolons to terminate statements. The compiler will generate an error message indicating a possible syntax or parsing error, prompting the programmer to correct the code by reinstating the semicolon .

Vous aimerez peut-être aussi