Advertisement
jasonpogi1669

Count Odd Numbers in a given range using C++

Feb 14th, 2022
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int l, r;
  7.     cin >> l >> r;
  8.     int start = l / 2;
  9.     int end = (r + 1) / 2;
  10.     int odd = end - start;
  11.     cout << odd << endl;
  12.     return 0;
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement