Thread: Hi guys, newbie here, some questions!

  1. #46
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You need to understand about how division works.
    There are two types of numbers in C. One is integers, whole numbers. One is floating point, decimal numbers.
    If you need/want the decimals, you need to make sure one variable is a floating point. You can do it via a simple cast.

    Then, you need to tell printf that it's actually printing a floating point number. This can be done via %f.

    So, all in all, it might look like:
    Code:
    float word_average = (float)letter_count/word_count;
    printf("%f", word_average);
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #47
    Registered User
    Join Date
    Feb 2008
    Posts
    26
    If your going to keep adding, might I suggest organizing this into seperate functions.

    Also a debugger usually helps to, it allows you to step through your code and look at variables. Visual Studio is good about this and gdb-insight is good as well, although it takes forever to build the files.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. Pipes, inheritence, newbie questions
    By grasshopa in forum Windows Programming
    Replies: 0
    Last Post: 02-28-2006, 06:17 AM
  3. Newbie IO questions
    By gustavosserra in forum C Programming
    Replies: 5
    Last Post: 08-29-2003, 08:09 AM
  4. More newbie questions
    By sunzoner in forum C++ Programming
    Replies: 3
    Last Post: 06-11-2002, 06:23 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM