Thread: need to solve simple c problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    8

    Exclamation need to solve simple c problem

    Problem Name: Y = MX
    Everyone know that the equation of a straight line is Y = MX + C. But if C = 0, then the straight line is passing through the origin. Here I always put C = 0. So our equation will be always Y = MX. Straight line is a geometrical term but my problem is not geometrical. I just use the equation Y = MX. Since Y = MX, so Y is must be divisible by M and X, and for a specific value of Y and various value of M and X, the equation must be satisfy.
    But in this problem we find (N) the number of M and X that satisfy the equation with condition M must be less than X (M16 = 1 * 16 (1<16) so it is countable.
    16 = 2 * 8 (2<8) so it is countable.
    16 = 4 * 4 (4 = 4) so it is not countable.
    16 = 8 * 2 (8>2) so it is not countable.
    16 = 16 * 1 (16>1) so it is not countable.
    So our answer N=2.

    So your duty is to find out how many way to find M and X (M
    Input: You have to provide an integer Y (1<=Y<=10000).

    Output: You just print the value of N.

    Sample input:
    16

    Sample output:
    2

    what output i'll get for following those input 128,500,666,1000,10000?
    i need code and solution

    i tried many time but can't get logic. how i improve my logic?
    help to clera this program logic concept. ... Shift+R improves the quality of this image. Shift+A improves the quality of all images on this page.
    Code:
    #include<stdio.h>
    int main()
    {
        
        int a,b,c=1,i;
        scanf("%d",&a);
        for(i=2;i<=a;i+=2)
        {
            if((a%i)==0)
            {
            printf("%d ",i);
            b=(a%i);
            }
    
            if(b>i)
             c++;
    
        }
    
        printf("\n%d",c);
    }
    Last edited by raihan004; 09-15-2012 at 02:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. switch statement. simple to solve but i dunno whats wrong.
    By ingeniousreader in forum C Programming
    Replies: 2
    Last Post: 05-17-2012, 09:43 AM
  2. C++problem to solve
    By truetrini20 in forum C++ Programming
    Replies: 9
    Last Post: 06-29-2010, 03:19 AM
  3. Simple loop problem I cant seem to solve
    By LightYear in forum C Programming
    Replies: 8
    Last Post: 03-21-2010, 06:59 PM
  4. simple i/o error that I cannot solve
    By CodeMonkey in forum C++ Programming
    Replies: 10
    Last Post: 12-17-2006, 04:07 PM
  5. problem cant solve please help.
    By sarah in forum C Programming
    Replies: 6
    Last Post: 09-03-2001, 01:32 PM

Tags for this Thread