Canna

Monday, 24 September 2018

Number Generation

  • Problem Description

    can you help to Manju to identify the result for the following problem? Manjus maths teacher first give the limit.Manju have to generate numbers between the limit which are divisible by 2. At the same time the numbers should not be divisible by 3 and 5
  • Test Case 1

    Input (stdin)
    1
    
    10
    
    
    Expected Output
    2
    
    4
    
    8
  • Test Case 2

    Input (stdin)
    20
    
    30
    
    
    Expected Output
    22
    
    26
    
    28
  • Program
  • #include <stdio.h>
    int main()
    {
      int a,b;
      int i;
      scanf("%d\n%d",&a,&b);
      for(i=a;i<=b;i++)
        {
        if(i%2==0 && i%3!=0 && i%5!=0)
          printf ("\n%d",i);
      }
    
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.