155 75 692KB
Romanian Pages 110
Limbajul C pentru clasa a IX-a
1
____________________________________________________Cuprins Cap.1 Elemente de bază ale limbajului C..................................................................................1 1.1 Structura unui program C ______________________________________________________1 1.2 Vocabularul limbajului_________________________________________________________1 1.3 Tipuri de date________________________________________________________________1 1.4 Directive preprocesor__________________________________________________________2 1.5 Exerciţii şi teste grilă__________________________________________________________2
Cap.2 Tipuri fundamentale de date ...........................................................................................4 Tip.........................................................................................................................................4 Număr de biţi........................................................................................................................4 Domeniu de valori................................................................................................................4 2.1 Constante___________________________________________________________________4 Exemple :
123.4
12e6
-111.2 ______________________________________________5
2.2 Variabile_____________________________________________________________________5 2.3 Exerciţii şi teste grilă__________________________________________________________5
Cap.3 Funcţii de intrare/ieşire standard....................................................................................7 3.1 Clasificarea funcţiilor de intrare/ieşire____________________________________________7 3.2 Funcţiile getch şi getche_______________________________________________________7 3.3 Funcţia putch________________________________________________________________7 3.4 Macrourile getchar şi putchar___________________________________________________8 3.5 Funcţiile gets şi puts__________________________________________________________9 3.6 Funcţia printf_________________________________________________________________9 3.7 Funcţia scanf________________________________________________________________11 3.8 Exerciţii şi teste grilă_________________________________________________________13
Cap.4 Operatorii limbajului C..................................................................................................18 4.1 Precedenţa operatorilor_______________________________________________________18 4.2 Operatorul de atribuire simplă__________________________________________________19 4.3 Operatori aritmetici___________________________________________________________19 4.4 Operatorii relaţionali__________________________________________________________20 4.5 Operatori logici______________________________________________________________20 4.6 Operatorii la nivel de bit_______________________________________________________21 4.7 Operatori compuşi de atribuire_________________________________________________22 4.8 Operatorul de conversie explicită (cast)__________________________________________23 4.9 Operatorul sizeof_____________________________________________________________23 4.10 Operatorii de adresare_______________________________________________________23 4.11 Operatorul condiţional_______________________________________________________23 4.12 Operatorul virgulă___________________________________________________________24
Limbajul C pentru clasa a IX-a
2
4.13 Exerciţii şi teste grilă________________________________________________________24
Cap.5 Instrucţiunile limbajului C............................................................................................29 5.1 Instrucţiunea vidă___________________________________________________________29 5.2 Instrucţiunea expresie________________________________________________________29 5.3 Instrucţiunea compusă_______________________________________________________30 5.4 Instrucţiunea if______________________________________________________________30 5.5 Funcţia standard exit_________________________________________________________32 5.6 Instrucţiunea while___________________________________________________________33 5.7 Instrucţiunea for_____________________________________________________________34 5.8 Instrucţiunea do-while________________________________________________________36 5.9 Instrucţiunea continue________________________________________________________38 5.10 Instrucţiunea break_________________________________________________________39 5.11 Instrucţiunea switch________________________________________________________40 5.12 Instrucţiunea goto__________________________________________________________42 5.13 Funcţiile standard sscanf şi sprintf_____________________________________________43 5.14 Header-ul ctype.h___________________________________________________________46
Macro de verificare.............................................................................................................46 5.15 Funcţii matematice uzuale___________________________________________________46
Valoarea returnată...............................................................................................................47 5.16 Exerciţii şi teste grilă________________________________________________________47
Cap.6 Tablouri...........................................................................................................................55 6.1 Declararea tablourilor________________________________________________________55
Exemple:.............................................................................................................................55 6.2 Iniţializarea tablourilor________________________________________________________55 6.3 Prelucrări elementare ale vectorilor____________________________________________56 6.3.1 Citirea elementelor unui vector________________________________________________56 6.3.2 Determinarea elementului minim/maxim________________________________________56 6.3.3 Determinarea primului element cu o anumită proprietate__________________________56 6.3.4 Determinarea ultimului element cu o anumită proprietate__________________________57 6.3.5 Eliminarea tuturor elementelor cu o anumită proprietate__________________________57 6.3.6 Eliminarea elementului din poziţia k dată (10) ? x=b : x=a;
43. Ce valoare afişează programul următor ? #include void main() { int x=5, y; y=(sizeof(x-1)==sizeof(int)) ? sizeof(‘x’) : sizeof(3); printf(“%d”, y); } a) 3 b) 1 c) 2 d) 4 e) programul este eronat 44. Ce valori va afişa programul următor ? #include void main() { int a=10, b=6, c=4, d; d=(c=a-6, a=b%c, b+=a, a/2); printf(“\n%d %d %d %d”,a,b,c,d); } a) 0 16 –6 5 b) 2 8 4 1 c) 4 2 8 1 d) –6 0 16 5 e) alte valori 45. Ce valoare afişează programul de mai jos ? #include void main() { int a=3, b=2, n=4, x; x=(a