Header Ads Widget

C++ program to check whether a number is divisible by 5 and 11 or not

 

 C++ program to check whether a number is divisible by 5 and 11 or not

Given a number , write a program to check whether it is divisible by 5 and 11 or not .

Sample input

55 

Sample output

55 is divisible by both 5 and 11

C++ program to check whether a number is divisible by 5 and 11 or not

The objective of the code is to find whether number is divisible by 5 and 11 or not .

Code(C++):-

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin>>a;
  if(a%5==0 && a%11==0)
   cout<<a<<" is divisible by both 5 and 11";
  else if(a%5==0)
   cout<<a<<" is divisible 5 ";
  else if(a%11==0)
    cout<<a<<" is divisible 11 ";
  else
    cout<<a<<" is not divisible 5 and 11 ";
}

Output:-

55
55 is divisible by both 5 and 11

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

Post a Comment

0 Comments