| Pseudocod | C++ |
|---|---|
| intreg x | int x |
| real x | float x; |
| x <- 3 | int x = 3; |
| citeste x | std::cin >> x; |
| scrie x | std::cout << x; |
| Daca x = 3 atunci | if(x == 3) { |
| instructiuni | // instructiuni |
| Altfel | } else { |
| instructiuni | // instructiuni |
| Sfarsit daca | } |
| Pentru contor <- valoare_initiala, valoare_finala, pas | for(int contor = valoare_initiala; contor <= valoare_finala; contor += pas) { |
| Executa | // instructiuni |
| Instructiuni | // instructiuni |
| Sfarsit pentru | } |
| Executa | do{ |
| Instructiuni | // instructiuni |
| Cat timp conditie | } while(conditie); |
| Repeta | do { |
| Instructiuni | // instructiuni |
| Pana cand conditie | } while(!conditie); |
| Cat timp conditie executa | while(conditie) { |
| instructiuni | // instructiuni |
| Sfarsit cat timp | } |
| Si | && |
| Sau | || |
| Mai mic: < | < |
| Mai mare: > | > |
| Mai mic sau egal: <= | <= |
| Mai mare sau egal: >= | >= |
| Egal: = | == |
| Diferit: <> | != |
#include <iostream> // pentru input/output
using namespace std;
int x; // variabilă globală întreagă
float y; // variabilă globală reală
void afiseazaMesaj() {
cout << "Salut!" << endl;
}
int main()main().
int a, b; // variabile locale întregi
float suma = 0; // variabilă locală reală
cout << "Introduceti un numar: ";
cin >> a;
suma = a + 10;
cout << "Suma este: " << suma << endl;
return 0;