top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

–1 vote
1,581 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 by As M Ob

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
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.
}
answer Nov 18, 2013 by Salil Agrawal
but i want it without function
Similar Questions
0 votes

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)

0 votes

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?

0 votes

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 ?

+2 votes

I know a slot will be of 0.5ms and useful symbol duration is 66.67micro sec. And if I divide them i.e (0.5ms)/(66.67 micro sec) the result will be 7.49. Can i assume it as normal symbol?? If so what will be the similar calculation for extended symbol??

...