c 2b 2b print the amount of odd integer between n and m

Solutions on MaxInterview for c 2b 2b print the amount of odd integer between n and m by the best coders in the world

showing results for - "c 2b 2b print the amount of odd integer between n and m"
Joleen
30 Feb 2019
1void oddNumbers(int n)
2{
3    int i;
4    for (i = 1; i <= n; i++) {
5        //condition to check ODD numbers
6        if (i % 2 != 0)
7            cout << i << " ";
8    }
9    cout << "\n";
10}
11
12// main code
13int main()
14{
15    int N;
16    // input the value of N
17    cout << "Enter the value of N (limit): ";
18    cin >> N;
19
20    cout << "EVEN numbers are...\n";
21    evenNumbers(N);
22
23    cout << "ODD numbers are...\n";
24    oddNumbers(N);
25
26    return 0;
27}
Lilly
06 Aug 2018
1// C++ program to print all
2// Even and Odd numbers from 1 to N
3
4#include <iostream>
5using namespace std;
6
7// function : evenNumbers
8// description: to print EVEN numbers only.
9void evenNumbers(int n)
10{
11    int i;
12    for (i = 1; i <= n; i++) {
13        //condition to check EVEN numbers
14        if (i % 2 == 0)
15            cout << i << " ";
16    }
17    cout << "\n";
18}
19
20// function : oddNumbers
21// description: to print ODD numbers only.
22void oddNumbers(int n)
23{
24    int i;
25    for (i = 1; i <= n; i++) {
26        //condition to check ODD numbers
27        if (i % 2 != 0)
28            cout << i << " ";
29    }
30    cout << "\n";
31}
32
33// main code
34int main()
35{
36    int N;
37    // input the value of N
38    cout << "Enter the value of N (limit): ";
39    cin >> N;
40
41    cout << "EVEN numbers are...\n";
42    evenNumbers(N);
43
44    cout << "ODD numbers are...\n";
45    oddNumbers(N);
46
47    return 0;
48}
49