write a complete c++ program that prompts the user to enter an integer, checks whether the integer is an odd number and divisible by 7, and prints an appropriate message.
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cout<<"Enter any number : "<<endl;
cin>>n;
if(n%2 !=0 && n%7 == 0)
{
cout<<"The entered number is odd and divisible by 7"<<endl;
}
else if(n%2 ==0 && n%7 ==0)
{
cout<<"The entered number is even and divisible by 7"<<endl;
}
else if(n%2 !=0 && n%7 !=0)
{
cout<<"The entered number is odd and not divisible by 7"<<endl;
}
else if(n%2 ==0 && n%7 !=0)
{
cout<<"The entered number is even and not divisible by 7"<<endl;
}
}
Comments
Leave a comment