help for a beginner.

This is a discussion on help for a beginner. within the C Programming forums, part of the General Programming Boards category; hello, i was wondering if you could help me. i am writing simple programs to help me get started in ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    44

    help for a beginner.

    hello,

    i was wondering if you could help me. i am writing simple programs to help me get started in c and have a problem. when i run the program it just runs through and does not give me time to read the results. is this because the compiler i am useing or is it something i am not putting into the program.

    i am useing Dev-C++ to compile.

    this is a sample program i made:

    #include <stdio.h>
    main()

    {

    float num ;

    printf ( "please enter a number \n" );
    scanf ( "%f" ,&num ) ;

    if (num <= 0)
    printf ( " the number was less than 0 \n" );

    else
    printf ( "the number was greater than 0 \n" );

    scanf ( "%f" ,&num ) ;
    }

    thanks,

    Dave.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    44
    that worked but int he book i am reading the author never mentions or uses the "getch()" in his programs and they still pause before the desplay disapears.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    It is because of your compiler that you have to use getch() or another input to pause your program. I used to use devc++, and always used the above, now i have a different compiler which allows me to close my program as in any other window.
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    44

    Smile

    could you tell me which compiler u are useing and if it is not too much trouble where i might download a copy, if it is downloadable.

    Thanx,

    Dave.

  5. #5
    Unregistered
    Guest
    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    printf("Hello World\n");

    system("PAUSE"); /*will pause and display such message untill key press*/
    /*and then dispay the next line*/
    printf("Hello World One\n");
    system("PAUSE"); /*will pause and display such message untill key press*/
    /*and then dispay the next line*/
    printf("Hello World Two\n");
    system("PAUSE"); /*will pause and display such message untill key press*/
    /*and then dispay the next line*/
    printf("Hello World Three\n");
    system("PAUSE"); /*will pause and display such message untill key press*/
    return 0; /*and this key press will close program*/
    }

    /*this question is asked so many times that the board is full of answers like
    the one above and other solutions, why does no one bother with search on the
    board, to lazy??????*/


    sall

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 12:48 PM
  2. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 03:02 PM
  3. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21