Write a program to find whether the entered number is divisible by 10 or not
Answers
Answer:
First of all before writing a program you should be clear about which logic you should use for the given problem in the program.
Here you should first input a number from the user. Second you should apply the logic of modulus as it gives the remainder in the division method. By putting if else and using the remainder condition in if you can easily display the text wether it is divisible or not.
Consider the program:
void main()
{
int a;
cout<< “ enter a number whose divisibility you want to check with 10”;
cin>>a;
if ( a%10==0)
{cout<<”number is divisible by 10″;}
else
cout<<”number is not divisible by 10″;
getch ();
}
First of all before writing a program you should be clear about which logic you should use for the given problem in the program.
Here you should first input a number from the user. Second you should apply the logic of modulus as it gives the remainder in the division method. By putting if else and using the remainder condition in if you can easily display the text wether it is divisible or not.
Consider the program:
void main()
{
int a;
cout<< “ enter a number whose divisibility you want to check with 10”;
cin>>a;
if ( a%100==0)
{cout<<”number is divisible by 100″;}
else
cout<<”number is not divisible by 100″;
getch ();