Thread: Newbie needs help

  1. #1
    Registered User
    Join Date
    Oct 2016

    Smile Newbie needs help


    Hello guys. I'm pretty new to programming with C and i got a small question.
    My program is:
    #include <stdio.h>
    int main()
        printf("Enter an amount: ");
        double b = 0;
        scanf("%lf", &b);
        printf("With tax added : ");
        printf(" ");
        printf("%.2f\n", b * 1.2);
        return 0;
    i know i could do the 3 printf's is 1 but it soesnt work either way.
    after all it should say:" Enter an amount: With tax added : 120.60"
    The thing is i got no idea how to make the space before "120.60"
    It's always just:"Enter an amount: With tax added :120.60", but i need that space there. ._.
    I've been trying for one hour but somehow i can't find a solution.

    Would be cool if someone could help me.

    Edit: Problem solved.
    It was using somethign from another file so it didnt change when i changed the program.
    Last edited by Muh9009; 10-11-2016 at 02:22 PM.

  2. #2
    Registered User
    Join Date
    May 2012
    Consoles are line-oriented. So user composes a whole line, then submits it to you. It follows that, at least at first, you should output and input whole lines.

    Print the prompt, followed by a newline.
    The call scanf, and add a newline to the format string on the end. That tells scanf to input the entire line.
    Then print the result, followed by an newline.

    Keep the dialog going with the user. Output a whole line, input a whole line.

    (you can make consoles work in different ways, but normally people pass special control codes to achieve this, and whilst not exactly advanced programming, it's not for a very beginner).
    I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
    Visit my website for lots of associated C programming resources.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hello, I am a newbie and so I have a newbie question;)
    By piratemonkey247 in forum C Programming
    Replies: 4
    Last Post: 12-20-2012, 10:59 AM
  2. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  3. newbie q!
    By xzentorian in forum C++ Programming
    Replies: 6
    Last Post: 12-19-2004, 04:38 PM
  4. C++ newbie needs help
    By random_dave in forum C++ Programming
    Replies: 5
    Last Post: 12-01-2004, 05:31 PM
  5. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 12:27 PM

Tags for this Thread