Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

write a program to display odd numbers between two numbers using while loop

0 votes
asked Apr 11, 2018 by anonymous

2 Answers

+1 vote
answered Apr 11, 2018 by anonymous
#include<iostream>
using namespace std;

int main()
{

   int number;
    int n;

    cout << "Enter value less than 100: ";
    cin >> n;

    while (n <= 100)
    {
        for(number = n; number <= n; number++)
        {
            if(number % 2 !=0)
            {
                cout << "The odd numbers are:" <<number << endl;
            }
        }
    }
}
0 votes
answered Apr 11, 2018 by anonymous
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

void odd(int a,int b){
    
    cout<<"Odd Values are : ";
    int i = a;
    while(i!=b){
        if(i%2 != 0){
            cout<<i<<" ";
        }
        i++;
    }
    
}

int main()
{
    int x,y;
    cout<<"Enter min value : ";
    cin>>x;
    cout<<"Enter max value : ";
    cin>>y;
    odd(x,y);
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...