the very basics

This is a discussion on the very basics within the C Programming forums, part of the General Programming Boards category; I am just starting out trying to learn this program...from the very very basic point. I'm working on my second ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    16

    Question the very basics

    I am just starting out trying to learn this program...from the very very basic point. I'm working on my second project and the book nor the teacher helps at all. Here is what my program is supposed to do:

    your input file could look something like this.

    2 // total number of students
    5 Terry 100 100 100 100 100 // the first student “record”
    2 Susan 100 100 // the next student “record”


    your OUTPUT should look something this:

    Student name: Student Average: Min: Max:
    Name1 average1 min1 max1
    Name2 average2 min2 max2

    I got the code that asks the user for the total number of students but as far as entering the 'number of grades to be input into the program' such as the '5' before Terry, then be able to type Terry and the five grades all on the same line. I have no idea how to do this. My professor just assumes we know all these codes and forgets its an introductory course and this is all new to me. He mentioned something to the effect of using " .h " header files? Does this make sense? Somehow I think I need to link different files to a main one but I don't know why I would need numerous files and have them all linked. I'm really confused on where to go after asking the user for the total number of students that need their average, min, and max grades computed. Can anyone head me in the right direction? I would like to know why certain codes need to be written particular ways, why i need to make different files and so on, to give me a better understanding so i can pass my midterm exam in a couple weeks. If someone would like to get me started that would be great....thanks for your time.

  2. #2
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    472
    Post your attempt in code.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I would like to know why certain codes need to be written particular ways, why i need to make different files and so on, to give me a better understanding so i can pass my midterm exam in a couple weeks.
    I guess you should have paid attention in class, eh?


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Sep 2005
    Location
    Sydney
    Posts
    60
    Ok, for getting formatted input like that, you should read up on the scanf() function, or better yet, fgets() and sscanf(). As for header files, there are two main reasons you need to know about them. The first is so that you can use the standard libraries (which include functions, such as fgets() and scanf(), that you will need for this project). To include standard libraries, you put a line at the top of your program like this:
    Code:
    #include <some_header_file.h>
    Header files can also be used to split your project across multiple files. Doing that is somewhat more difficult than just including standard libraries - if you're looking at having multiple files, go do some research on the preprocessor commands (#include is one example of a preprocessor command). Essentially, when you use multiple files, you put all your function declarations, type definitions etc. in a .h file, then include that in all the .c files that need it.

  5. #5
    Registered User Baaaah!'s Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    23
    I'm not sure that you'd really need to have multiple files for a program of this size - unless of course the object of the lesson was to get you writing your own header files. Are you sure that your prof wasn't simply referring to the header files you have to include inorder to get the program functioning correctly?

    Either way you might want to look at structures as well, as these I think are well suited to this sort of data storage.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Learned the basics, SO ?
    By TuxPayne in forum C Programming
    Replies: 4
    Last Post: 09-11-2005, 12:32 PM
  2. "Modern C++ and Basics of OO Programming" (e-learning course)
    By Erhard Henkes in forum C++ Programming
    Replies: 5
    Last Post: 09-16-2004, 03:01 PM
  3. C++ Basics part two
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 11-22-2003, 10:34 AM
  4. Desire & Fear: Two Basics of Human..
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-16-2002, 10:11 PM
  5. The Basics
    By Granger9 in forum Windows Programming
    Replies: 5
    Last Post: 09-13-2002, 05:12 PM

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