The question is to display enter any odd number when a even number is entered and vice versa with in a specific range given by users. If the number enter by user is not in range then it will display invalid number. The range is given by user. Here my if condition is not working; it always displays "enter an odd number" even if I have entered an odd number
#include<iostream>
#include<math.h>
using namespace std ;
int main()
{
int firstlimit = 0 ;
int secoudlimit = 0 ;
int x = 0 ;
cout << " \n first limit : " ;
cin >> firstlimit ;
cout << " \n secound limit : " ;
cin >> firstlimit ;
cout << "\n enter any number : " ;
cin >> x ;
if (x < firstlimit ^ x > secoudlimit )
{
cout << "INVALID NUMBER\n" ;
cout << "\n enter any number : " ;
cin >> x ;
}
if (x/2)
{
cout << "Enter any odd number : " ;
cin >> x ;
}
else
{
cout << "Enter any even number : ";
cin >> x ;
}
return 0 ;
}
Aucun commentaire:
Enregistrer un commentaire