Help me in solving CND72V2 problem

My issue

My code

#include <bits/stdc++.h>
using namespace std;

int main() {

  int a;
  int b;
  a = 15;
  b = 35;
  if (a%7 == 0 && a%5 == 0 ) {
    cout << "The number is divisible by both 5 & 7" << endl;
  }  
  else {
    cout << "The number is not divisible by both 5 & 7" << endl;
  }

  if (b&7 == 0 && b&5 == 0 ) {
    cout << "The number is divisible by both 5 & 7" << endl;
  } 
  else {
    cout << "The number is not divisible by both 5 & 7";
  }
  
  return 0;
}

Learning course: Learn C++
Problem Link: CodeChef: Practical coding for everyone

your mistake occures in second if statement so you write code like this…

if (b%7 == 0 && b%5 == 0 ) {
cout << “The number is divisible by both 5 & 7” << endl;
}

1 Like

Hello, the mistake here is in the 11th line of your program, b&7 and b&5 results in error, So, to find the remainder obtained You need to change it to b%7 ==0 && b%5

1 Like