Advertisement
vertc

06-12

Dec 6th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int i=1;
  7.     while(i<=10) {
  8.         cout<<i<<" ";
  9.         i = i+1;
  10.     }
  11. return 0;
  12. }
  13.  
  14. -------------------------------------------------------------------------------------
  15.  
  16. #include <iostream>
  17.  
  18. using namespace std;
  19.  
  20. int main() {
  21.     int i=1, suma=0;
  22.     while(i<=10) {
  23.         i = i+1;
  24.         suma = suma + i;
  25.     }
  26.     cout<<suma;
  27. return 0;
  28. }
  29.  
  30. -------------------------------------------------------------------------------------
  31.  
  32. #include <iostream>
  33.  
  34. using namespace std;
  35.  
  36. int main() {
  37.     int i=1, j=2, suma=0;
  38.     while(i<=10) { // lub i<=11
  39.         suma = suma + j;
  40.         j = j+2;
  41.         i = i+1;
  42.     }
  43.     cout<<suma;
  44. return 0;
  45. }
  46.  
  47. -------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement