In: Computer Science
Code in C ++ that asks the user for an integer and that prints whether or not the number is divisible by three in the integers. If the number is not divisible by three, the program must write a message indicating what the remainder is obtained by dividing the number by three.
Note: If u like the do Give it a Thumbs Up and have any doubt feel free to ask in comments , I will rely asap
Code in C++ To check whether the entered number is divisible by 3 or not and if not then show a message that it is not divisible along with the remainder .
Code is
#include <iostream>
using namespace std;
int main() {
int num;
cout<<"Enter an Integer: ";
cin>>num;
// check the num given is divisible by 3 or not So to do
that
// we use Modulus operator % . This operator will give the
remainder
// so if remainder is 0 then we say it is divisible else not
if( num % 3 != 0)
// it will print only when number is not divisible by 3 along with
remainder
cout<<"\nNumber is not Divisible and remainder is
"<<num%3<<endl;
return 0;
}
Code Screen Shot
Output
This is how we can write the Code in C++ to get the desired result
Thank You