Answer to Question #188827 in C++ for naura

Question #188827

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.


1
Expert's answer
2021-05-04T14:15:08-0400
#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;
	}
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS