cant get a basic input/output program to work.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kevincol54
    New Member
    • Feb 2012
    • 1

    cant get a basic input/output program to work.

    im trying to write a program that prompts the user to enter three numbers and then prints them vertically (each on one line), first forward and then reversed. this is how the design should look:

    please enter three numbers: 1 43 54
    your numbers fowards:
    1
    43
    54

    your numbers backwards:
    54
    43
    1

    this is what i have thus far when it comes to code....

    Code:
    
    #include <stdio>
    
    int main (void)
    {
    // local declarations 
    int a;
    int b;
    int c;
    
    //statments
    printf ("\nwelcome, this program outputs stuff you input\n");
    printf ("Enter three numbers");
    printf ("in the form: nnn nnn nnn <return>\n");
    scanf ("%d %d %d", &a, &b, &c);
    
    printf ("these are your numbers forward");
    printf ("inta\v intb\v intc\n")
    
    printf ("these are your numbers backwards");
    printf ("intc\v intb\v intc\n");
    
    return 0;
    }

    can someone tell me where i am going wrong and what i need o do to fix it? Thanks!
    Last edited by Rabbit; Feb 29 '12, 06:16 AM. Reason: Fixed code tags.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You are not using printf correctly.

    You have this:
    Code:
    printf ("intc\v intb\v intc\n");
    when you sould have this:
    Code:
    printf ("%d\n%d\n%d\n", a,b,c);
    Remember, your variables are named a,b and c and not inta, intb and intc. Also, inorder to display your variables, printf requires a parameter string that contains the format. %d means an integer.

    Take some time to read up on this.

    Comment

    Working...