Professional Documents
Culture Documents
BPC
BPC
Biblioteca
#include<stdio.h>
#include <math.h> pt functii matematice
Scriere
printf(" ")
initializare
scanf("%d", &myNum);
Hello world!
I am learning C.
It's amazing
Tipuri de variabile
int "%d\n" sau "%i\n" printf("%d\n", sum);
float "%f\n"
char "%c\n"
string (text) "%S\n"
long unsigned int "%lu\n"
#include<stdio.h>
int main()
{prinf("Hello world");
structuri
if(conditie){ }
else {}
int time=15;
(time<18){}
else{}
switch()
exemplu
int day=3
switch(day){
case 1:
printf("luni");
break;
case 2:
printf("marti");
break;
case 3:
printf("miercuri"):
break;
defalut:
printf("nu e niciuna");
}
//Scrie mircuri
while
while(conditie)
{}
do while
do{
}while(conditie);
for
exemplu
for(i=1;i<=5;i++)
{}
break&continue;
continue
exemplu
for (i = 0; i < 10; i++) {
if (i == 4) {
continue;
}
scrie
0
1
2
3
5
6
7
8
9
VECTORI
printf("%d", myNumbers[0]);
MATRICE
int matrix[2][3] = { {1, 4, 2}, {3, 6, 8} };
printf("%d", matrix[0][2]);
STRING
char greetings[] = "Hello World!";
sau char greetings[] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!',
'\0'};
printf("%s", greetings);
printf("%c", greetings[0]); //afiseaza doar prima litera
Functii matematice
abs(x) Returns the absolute value of x
acos(x) Returns the arccosine of x
asin(x) Returns the arcsine of x
atan(x) Returns the arctangent of x
cbrt(x) Returns the cube root of x
cos(x) Returns the cosine of x
exp(x) Returns the value of Ex
sin(x) Returns the sine of x (x is in radians)
tan(x) Returns the tangent of an angle
ceil() rotunjeste la mai mare
fl0or() rotunjeste la mai mic
pow()