Write a program that uses for loops to perform the following steps:
Output all odd numbers between firstNum and secondNum. Hint: the difference between two consecutive is 2.
#include <iostream>
using namespace std;
int main() {
const int firstNum = 3, secondNum = 26;
for(int i = firstNum; i <= secondNum; i++) {
if(i % 2) {
cout << i << " ";
}
}
cout << "\n";
return 0;
}
Comments