Thread: HELP!! College Assignment

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Question HELP!! College Assignment

    could do with a bit of help out there off anyone who knows much bout c im a complete novice here
    so far we have only been doing code using #include<stdio.h>

    much appreciated from who ever helps me out here

    The main function is to consist of function calls only.

    At least three functions are to be used to allow the user to:
    1. Input the names and surnames of up to 30 students, using a for loop.
    2. Input the names of up to six subjects, using a while loop.
    3. Input the marks achieved by each student in the subjects, using a do while loop.
    4. Calculate the average mark for each student.
    5. Output the name and average mark for each student.

    The user is to be allowed repeat the entire process as often as she wishes.

    i have a sample one here that needs to be modified help would be much appreciated
    Code:
    #include<stdio.h>
    char Names[30][10];
    int SUB1[30];
    int SUB2[30];
    int SUB3[30];
    float AVG[30];
    int num,i,val;
    main()
    {
    clrscr();
    select();
    }
    select()
    {
    printf("\n do you want to input or to exit?");
    printf("\n input 1 to go to input function 2 to exit");
    scanf("%d",&val);
    if(val==1)
    input();
    else
    exit(1);
    }
    input()
    {
    i=0;
    printf("\n how many names do you want to input?");
    scanf("%d",&num);
    for(i=0;i<num;i++)
    {
    printf("\n what is the name %d: ?",i+1);
    scanf("%s",&Names[i]);
    printf("\n what is mark %d:?",i+1);
    scanf("%d",&SUB1[i]);
    printf("\n what is mark %d:? for sub 2",i+1);
    scanf("%d",& SUB2[i]);
    printf("\n what is mark %d:? for sub3 ",i+1);
    scanf("%d",&SUB3[i]);
    }
    calc();
    getch();
    }
    calc()
    {
    i=0;
    while(i<num)
    {
    AVG[i]=(SUB1[i]+SUB2[i]+SUB3[i])/3;
    i++;
    }
    output();
    }
    output()
    {
    i=0;
    do
    {
    
    printf("\n your name is : %s",Names[i]);
    printf("\n your marks are : %d %d %d",SUB1[i],SUB2[i],SUB3[i]);
    printf("\n your average is: %5.2f",AVG[i]);
    i++;
    }
    while(i<num);
    getch();
    Repeat();
    }
     Repeat()
     {
     int val1;
     printf("\n do you want to repeat or to exit?");
     printf("\n input 1 to go to select() function ,2 to exit");
     scanf("%d",&val1);
     if(val1==1)
     select();
     else
     exit(1);
     }

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    >>i have a sample one here that needs to be modified help would be much appreciated
    That means you haven't put in any effort yet.
    We are not going to do your homework for you. Read homework policy.
    Indent your code too!!

  3. #3
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    First, indent your code.
    Second, what is your exact problem?
    Third, study about strings.
    Forth, use std:uts() instead of scanf().

    It's
    Code:
    std::puts()
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

  4. #4
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    This is C forum, no C++.

  5. #5
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Can't you put puts() in c???
    I think you should better look at it..
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

  6. #6
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Code:
    std::puts()
    Ask yourself. Is it C or C++?
    Sure plain puts() is a C function. If you are not sure, try to compile with a C compiler.

  7. #7
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Lol... My bad.... In code...
    Sorry... Code was of c++...
    Good Bayint Naung...
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

  8. #8
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Forth, use std:uts() instead of scanf().
    This is C forum
    Please take a moment to think before posting answers, consider if the advice is accurate, and useful first.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  9. #9
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Quote Originally Posted by rogster001 View Post
    This is C forum
    Please take a moment to think before posting answers, consider if the advice is accurate, and useful first.
    1. There is nothing like std:uts(). :-@
    2. I already mentioned that my bad, that means, that was a mistake...
    3. Sorry.
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu
    By Krush in forum C Programming
    Replies: 17
    Last Post: 09-01-2009, 02:34 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  4. Should I go to a state college and be 20k in debt, or a private college and be 90k in
    By Terrance in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-10-2003, 08:22 PM
  5. College or No College :: Future
    By kuphryn in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 09-25-2002, 03:48 PM