desislava_topuzakova

03. Numbers 1...N with Step 3

Jan 31st, 2022
1,115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. // 03. Numbers 1 to n over 3.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     //отпечатвам всички числа от 1 до n през 3
  10.     int n;
  11.     cin >> n;
  12.     //повтарям: печатането на число
  13.     //начало: 1
  14.     //край: n
  15.     //промяна: +3
  16.  
  17.     //цикъл със стъпка - цикъл, в който имаме промяна различна от ++
  18.  
  19.     for (int number = 1; number <= n; number = number + 3)
  20.     {
  21.         cout << number << endl;
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment