DEV Community

Junior-Dev
Junior-Dev

Posted on

C programming | Step By Step 🔴⚪

#c

Kol chay b Tounsi

Introduction

C hiya min a9dem l programming languages, w biha hiya t3amlou programming langues okhrine (ruby, python, ...).
C language 9weya barcha w mousta3mla b kathra.

C Compiled language, ma3neha lezem l code l tektbou enti (c) yetbadel l language tefhmou l machine bech tnajim tekhdem bih.
Human readable -> Machine readable

el faza eli tbadel l code nsamiwha Compiler ( exmpl : GCC ).

Dev Environment

Bech tnajem tProgrammi C, lezem t installi Compiler.

Windows : tnajim tsob IDE hadher (CodeBlocks, DevC++, ....), fih compiler by default.
Linux : Lezem Tsob Compiler (gcc) bech tnajim ta3ml (Compile, Run) b Terminal.

Browser : tnajim tekteb l code C f wahda ml platforms hedhom( Repl.it, onlinedb.com, ... ) w houma ytelhew b kol chay.

PS: ken theb ta3ref kifech thadher C Dev Environment click here.

First Code

Kima kol language, lezem net3adew b - Hello World! -
Ena bech nekhdem b DevC++

PS: l ouptput mta3 l programs l bech nekhdmouhom ykoun f terminal / cmd.

    #include<stdio.h>

    int main(){

        printf("Hello World !");
        return 0;

    }
Enter fullscreen mode Exit fullscreen mode

Chnowa l klem hedha lkol ?

    #include<stdio.h>
Enter fullscreen mode Exit fullscreen mode

Hiya library l tkhalina nektbou klem fel / 3le Terminal
std*IO*.h : input, output

Ya3ni l compiler kif yal9a

    printf("Hello World !");
Enter fullscreen mode Exit fullscreen mode

Bech yfarkes 3le " printf " chnowa ma3neha. Edheka 3lech 3tineh dictionary bech ynajem yefhimha.

" printf " tekteb klem 3le Terminal (msg)


    int main(){

    }
Enter fullscreen mode Exit fullscreen mode

Esmha yfaserha, main heya l function l esesiya fel program., ya3ni l compiler yemchi toul liha hiya.
Tnajem tekteb functions okhrine (ama m tsamihomch main oc), w t3aytilhom fl main.

3lech hatina ( int ) ?

  • l functions 3andom return value, therefore return type.
    ya3ni l function traja3 value kif tkamil l execution.
    lahne type howa INT, khatir traja3 integer ( return 0, 1, 45, .... )

  • Tnajim f 3oudh int thot, lul, void. l main traja3 chay

    #include<stdio.h>

    void main(){
        printf("Hello World !");

    }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)