programe in c++ that decide if a number is divisible by 5 or any number using if else statment

 

c++ language
c++ language





Write a programe in c++ that decide if a number is dvisible by 5 or 11 or not using if else statment?

programe:

1)#include<iostream>

2)using namespace std;

3)int main()

4){

5)int  num;

6)cout<<"input a number";

7)cin>>num;

8)int ans1=num%5;

9)int ans2=num%11;

10)if(ans1==0&&ans2==0)

11){

12)cout<<num<<"is divisible by 5"<<endl;

13)cout<<num<<"is divisible by 11"<<endl;

14)}

15)else

16)if(ans1==0)

17)cout<<num<<"is divisible by 5";

18)else

19)if(ans2==0)

20)cout<<num<<"is divisible by 11";

21)return 0;

22)}

Description:

This programe is to decide wheather a number is divisible by 5 or 11 or any number in c++ programe.C++ is a programming language .In this programe we use if else statment to show weather a number is divisible by 5 or 11.c++ language is an object oriented programming language.

Post a Comment

0 Comments