# Whether the digit is divisible by 7 and 4 , 7 or 4 and 7 or 4 but not both.

–1 vote
1,305 views

write a program that ask the user to enter an integer and deter mines whether it id divisible by 7 and 4 .whether it id divisible by 7 or 4 .whether it id divisible by 7 or 4 but not both

for example . if your input is 28 , the output should be :
Is 28 divisible by 7 and 4 ? False
Is 28 divisible by 7 or 4 ? True
Is 28 divisible by 7 or 4 , but not both ? False

posted Nov 18, 2013

``````boolean is_divisible(int i)
{
if ((i % 7 == 0) && (i % 4 == 0))
return false; // Case when i is divisible by both
if ((i % 7 == 0) || (i % 4 == 0))
return false; // Case when i is divisible by only 7 or 4 not both
else
return true; // Case when i is not divisible by 7 or 4 or both, seems question is wrong so making this assumption.
}
``````
but i want it without function
Similar Questions

I can not compile

``````template
int parallel_sum(const RAIter beg, const RAIter end) {
const auto len = end-beg;
if(len < 1000) return std::accumulate(beg, end, 0);

const RAIter mid = beg + len/2;
auto handle = std::async(std::launch::async, parallel_sum, mid, end);
const int sum = parallel_sum(beg, mid);
return sum + handle.get();
}

int main() {
std::vector v(10000, 1);
std::cout
``````

using "g++ -Wall -std=c++11", but running it I get terminate called after throwing an instance of 'std::system_error' what(): Unknown error -1
Aborted (core dumped)

Anyhow PHY is appending 4bits of SFN with MIB payload, but As per RRC MIB payload it is not part of it. Why is this two type of MIB payload?

This code compiles on MSVC but not on G++ :

``````template
class B
{
public:
static void SomeMethod()
{
A::SomeMethod();
}
};

class A
{
public:
static void SomeMethod();
};

void test()
{
B::SomeMethod();
}
``````

The error with g++ is :

``````test.cpp: In static member function "static void B::SomeMethod()":
test.cpp:7:3: error: "A" has not been declared
``````

Is there is a option to indicate to g++ to evaluate the template functions only when a specialization is called, and not before ?