Thread: Help with "scanf"

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    20

    Help with "scanf"

    Here is my program so far....

    # include <stdio.h>
    main()
    {
    int count, abundant, perfect, deficient, sum=0, num;

    printf("Enter a number\n");
    scanf("%d", &num);

    printf("%20s%20s\n", "Number", "Type");
    printf("%20s%20s\n", "------", "----");

    for (count=1; count <= 20; count++);
    {
    sum=0;
    if((count%1) && (count==sum))
    printf("perfect\n");
    ~>scanf("%d", );
    else if((count%1) && (count<sum))
    printf("abundant\n");
    ~>scanf("%d", );
    else if((count%1) && (count>sum))
    printf("deficient\n");
    ~>scanf("%d", );
    }

    }
    I don't know what to type into he blank scanf's. The question is, A perfect # is a # which is the sum of all its divisors except itself. Six is the first perfect #; the only #s which divide 6 evenly are 1,2,3,6 and 6=1+2+3. An abundant # is one which is one less than the sum of its divisors
    (12 <1+2+3+4+6); a deficient # is greater than the sum of its divisors (9>1+3).
    Write a complete 'C' program which classifies each of the first N integers (where N is entered by the user) as either perfect, abundant, or deficient. The output should be formatted so that the program generates a table.
    It just prompts the user to input a #. Please help.
    Thanks,
    Kristina

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    For all of your ~> things, put in &var, where var is the variable you're inputting.

    I guess I might be missing the point of your program, but why do you ask for input in the for loop, anyways?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My "scanf"
    By marrk in forum C Programming
    Replies: 5
    Last Post: 11-22-2006, 06:33 AM