OneDrain

Untitled

Sep 9th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. /*
  6. 1. Adunati 2 numere.
  7. 2. Verificati daca numarul x este par (alegi tu x-ul).
  8. 3. Atata timp cat numerele dintr-un sir sunt pare (de la 1 la 20), afisati pe ecran PULENTIU. (NU TOATE TREBUIE SA FIE PARE)
  9. 4. Afisati dublul numerelor naturale dintr-un sir (de la 1 la 20)
  10. */
  11.  
  12. int a, b, suma = 0 ;
  13.  
  14. int x;
  15.  
  16. int main()
  17. {
  18.     cout << "PROBLEMA 1." << endl;
  19.     cin >> a >> b;
  20.     suma = a + b;
  21.     cout << "PROBLEMA 1: " << "suma = " << suma << endl << endl;
  22.  
  23.     cout << "PROBLEMA 2." << endl;
  24.     cin >> x;
  25.     if(x % 2 == 0)
  26.         cout << "PROBLEMA 2: " << x << " este PAR!" << endl << endl;
  27.     else
  28.         cout << "PROBLEMA 2: " << x << " NU este par..." << endl << endl;
  29.  
  30.     cout << "PROBLEMA 3." << endl;
  31.     for(int i = 1; i <= 20; i++)
  32.         if(i % 2 == 0)
  33.             cout << "PULENTIU" << endl;
  34.  
  35.     cout << endl << endl;
  36.     cout << "PROBLEMA 4." << endl;
  37.     int j = 1;
  38.     while(j <= 20)
  39.     {
  40.         cout << j * 2 << " ";
  41.         j++;
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment