Thread: I need some assistance! (First C program)

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    1

    I need some assistance! (First C program)

    well my first assignment for my CS102 class has already got me really confused seeing how i never even took CS101 to begin with.

    Sorry, but this needs to be written in C not C++, but im sure its so simple most of you can still help me.

    so heres the problem:
    Event..... Task ..... Number of Days
    1 ..... ..... 15 ..... ..... 3
    1 .......... 27 ..... ..... 6
    1 ..... ..... 36 ..... ..... 4
    2 ..... ..... 15 ..... ..... 5
    3 ..... ..... 18 ..... ..... 4
    4 ..... ..... 15 ..... ..... 2
    4 ..... ..... 26 ..... ..... 7
    4 .......... 27 ..... ..... 7
    5 ..... ..... 16 ..... ..... 4

    Write a program to read the critical path info and print a timetable that lists each EVENT NUMBER, THE MAX NUMBER OF DAYS FOR A TASK WITHIN THE EVENT, and THE TOTAL NUMBER OF DAYS FOR THE PROJECT COMPLETION.

    this is what i figure the output.txt should look like:

    Project completion timetable

    ------------------------------------------------
    Event ..... Num of tasks ..... Max num.of days
    1 .......... 3 ..... .......... 6
    2 .......... 1 ..... ..........5
    3 ..... ..... 2 ............... 4
    4 ..... ..... 3 ..... .......... 7
    5 ..... ..... 1 ..... .......... 4

    ------------------------------------------------
    Total number of days to finish the project: 26 days
    ------------------------------------------------
    Maximum number of tasks is 3
    Events 1, 4, have 3 tasks.
    ------------------------------------------------


    and heres what i got so far (not much):
    #include <stdio.h>

    int main(void)

    {
    /* Declare variables. */
    int event, task, days;

    /* Get user input from the keyboard.*/
    printf("Enter event number.\n");
    scanf(&#37;i,&event);
    printf("Enter task number.\n");
    scanf(%i,&task);
    printf(Enter number of days.\n");
    scanf(%i,&days);

    now im just wondering should i use a loop or something to get all the input data since there is alot of data to input, and this is supposed to work for all different types of tables as well.

    This is my first C program ever!, besides hello, world! so please be gentle.
    Thanks, this is such a long post that i'd really appreciate it if anyone actually reads thru the entire thing.
    Last edited by charmander; 08-05-2007 at 03:41 AM.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Use the code tags properly next time. They aren't overly complicated if you've used tags of almost any sort on forums before.

    Anyway, do you have a limit as to how many lines of input there can be? Or better yet actually, do you have a limit as to how many different events there can be? Using a linked list would be possible, or a growing array, but it sounds like that's slightly beyond your capabilities.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Location
    dehradun
    Posts
    5

    Smile

    you could use a 3 d array to store the input
    if u know the max limits for the no of events ,the tasks ,then u could use nested for loops for the job
    otherwise u could use the while loop by asking the user whether he has ne more data and putting the answer in the loop testing condition

  4. #4
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    you could use a 3 d array to store the input
    You mean 3 arrays, not a 3d array right? Which could also be done as one 2d array.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM