Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 32
  1. #11

    ...deleted...

  2. #12
    @sir darkhero: Bro, gigamit nako mostly imong code but I changed a few details, like making some parts into swith() statement, etc.. Anyways, thank you kaayo sa help! Here's my final code:

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<conio.h>
    
    #define FALSE 0
    
    typedef struct
    {
     char fname[40];
     char lname[40];
     char mi;
    }NAMETYPE;
    
    typedef struct
    {
     NAMETYPE name;
     long int id;
     char course[20];
     int year;
     float gpa;
    }STUDREC;
    struct node
    {
     STUDREC student;
     struct node *next;
    };
    typedef struct node nd;
    
    void DisplayMenu(void);
    void DeleteNode(nd *);
    void GetStudRec(nd *);
    void DisplayAllStudentRec(nd *);
    void Search(nd *);
    void DisplayTopStudent(nd *);
    void DisplayStudRec(STUDREC);
    void Pause(void);
    
    int main(void)
    {
     float x = 0;
     float *y = &x;
     x = *y;
     clrscr();
    
     DisplayMenu();
     return 0;
    }
    void DisplayMenu(void)
    {
     nd *record;
     int done = FALSE;
     char input;
    
     record = (nd *) malloc(sizeof(nd));
     record->next = NULL;
     while (!done)
     {
      printf("----------- MAIN MENU ------------\n\n");
      printf("(1) ADD STUDENT RECORD\n");
      printf("(2) SEARCH STUDENT RECORD\n");
      printf("(3) DISPLAY ALL STUDENT RECORDS\n");
      printf("(4) DISPLAY TOP STUDENT\n");
      printf("(5) EXIT\n\n");
    
      input = 0;
      while (!(input >= '1' && input <= '5'))
      {
       printf("Enter desired operation (1-5): ");
       scanf("%c", &input);
       getchar();
    
       if (!(input >= '1' && input <= '5'))
        printf("INVALID OPERATION. PLEASE TRY AGAIN.\n\n");
      }
    
      printf("\n");
      switch(input)
      {
       case '1':
        printf("------- ADD STUDENT RECORD -------\n\n");
        GetStudRec(record);
        break;
       case '2':
        printf("----- SEARCH STUDENT RECORD ------\n\n");
        Search(record);
        break;
       case '3':
        printf("-- DISPLAY ALL STUDENT RECORDS ---\n\n");
        DisplayAllStudentRec(record);
        break;
       case '4':
        printf("------- DISPLAY TOP STUDENT ------\n\n");
        DisplayTopStudent(record);
        break;
       case '5':
        printf("GOODBYE!\n");
        done = !FALSE;
        Pause();
        break;
      }
      printf("\n");
     }
    
     while (record->next != NULL)
     {
      nd *pointer;
      pointer = (nd *)malloc(sizeof(nd));
      pointer = record;
      free(record);
      record = pointer->next;
     }
    }
    void GetStudRec(nd *record)
    {
     int index = 1;
     STUDREC student;
    
     while (record->next != NULL)
     {
      index++;
      record = record->next;
     }
    
     printf("FIRST NAME of student %d: ", index);
     scanf("%s", student.name.fname);
     printf("LAST NAME of student %d: ", index);
     scanf("%s", student.name.lname);
     printf("MIDDLE INITIAL of student %d: ", index);
     scanf("%s", &student.name.mi);
     printf("ID NUMBER of student %d: ", index);
     scanf("%ld", &student.id);
     printf("COURSE of student %d: ", index);
     scanf("%s", student.course);
     printf("YEAR of student %d: ", index);
     scanf("%d", &student.year);
     printf("GPA of student %d: ", index);
     scanf("%f", &student.gpa);
    
     record->student = student;
     record->next = (nd *) malloc(sizeof(nd));
     record->next->next = NULL;
     record = record->next;
    
     getchar();
     Pause();
     clrscr();
    }
    void Search(nd *record)
    {
     int found = FALSE;
     long int id;
    
     printf("Student ID to search: ");
     scanf("%ld", &id);
     getchar();
    
     while (!found && record->next != NULL)
     {
      if (record->student.id == id)
      {
       printf("\nThe student you're looking for:\n\n");
       DisplayStudRec(record->student);
       found = !FALSE;
      }
      record = record->next;
     }
     if (!found)
      printf("\nSTUDENT ID DOES NOT EXIST!\n");
     Pause();
     clrscr();
    }
    void DisplayAllStudentRec(nd *record)
    {
     int index = 0;
     while (record->next != NULL)
     {
      index++;
      clrscr();
      printf("----------- MAIN MENU ------------\n\n");
      printf("(1) ADD STUDENT RECORD\n");
      printf("(2) SEARCH STUDENT RECORD\n");
      printf("(3) DISPLAY ALL STUDENT RECORDS\n");
      printf("(4) DISPLAY TOP STUDENT\n");
      printf("(5) EXIT\n\n");
      printf("-- DISPLAY ALL STUDENT RECORDS ---\n\n");
      DisplayStudRec(record->student);
      record = record->next;
      Pause();
      if (record->next != NULL)
       printf("\n");
      clrscr();
     }
     if (index == 0)
     {
      printf("NO STUDENT RECORD EXISTS!\n");
      Pause();
     }
     clrscr();
    }
    void DisplayTopStudent(nd *record)
    {
     int index = 0;
     STUDREC student;
     student.gpa = 0;
     while (record->next != NULL)
     {
      index++;
      if (student.gpa < record->student.gpa)
       student = record->student;
      record = record->next;
     }
     if (index > 0)
     {
      printf("STUDENT WITH THE HIGHEST GPA IS:\n\n");
      DisplayStudRec(student);
     }
     else
      printf("NO STUDENT RECORD EXISTS!\n");
     Pause();
     clrscr();
    }
    void DisplayStudRec(STUDREC student)
    {
     printf("ID Number: %ld\n", student.id);
     printf("Name: %s %c %s\n", student.name.fname, student.name.mi, student.name.lname);
     printf("Course: %s\n", student.course);
     printf("Year: %d\n", student.year);
     printf("GPA: %.1f\n", student.gpa);
    }
    void Pause(void)
    {
     char input = '\0';
     printf("\nPress ENTER to continue...");
     while (input != '\n')
      input = getchar();
    }
    @sir MarkCuering: Boxes? Unsa-on mana paghimo bro?

  3. #13
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    see ASCII table

  4. #14
    Quote Originally Posted by marcdaven View Post
    @sir darkhero: Bro, gigamit nako mostly imong code but I changed a few details, like making some parts into swith() statement, etc.. Anyways, thank you kaayo sa help! Here's my final code:
    no problem bro, maayo pud na imong gibuhat nga wala nimo gisundog ang tibuok code, plus points na para nko hehe. di parehas sa uban students nga akong nabantayan, kopya lang diretso, way effort miski gamay para sabton kung giunsa. sila ra jafon alkanse kay wa man silay nakat-onan bisan pasar pa. anyway... good luck sa programming.

  5. #15
    Quote Originally Posted by darkhero View Post
    no problem bro, maayo pud na imong gibuhat nga wala nimo gisundog ang tibuok code, plus points na para nko hehe. di parehas sa uban students nga akong nabantayan, kopya lang diretso, way effort miski gamay para sabton kung giunsa. sila ra jafon alkanse kay wa man silay nakat-onan bisan pasar pa. anyway... good luck sa programming.
    Lage bro, paet kaayo ang uban students nga ing-ana. Ganahan bya jud ko ma-master aning C para di ko maglisud sa uban programming languages (I think?)

    Thanks to all who helped me! KUDOS!

  6. #16
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    ur right but you should be doing OOP skills now.

  7. #17
    Quote Originally Posted by MarkCuering View Post
    ur right but you should be doing OOP skills now.
    kanang typedef structs (NAMETYPE/STUDREC) sa original code niya dili diay na basic skills sa OOP?

    sa akong tan-aw, ang purpose ani nga exercise kay data structures man (linked list). pakapin na lang na ang UI ug OOP.

  8. #18
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    Quote Originally Posted by darkhero View Post
    kanang typedef structs (NAMETYPE/STUDREC) sa original code niya dili diay na basic skills sa OOP?

    sa akong tan-aw, ang purpose ani nga exercise kay data structures man (linked list). pakapin na lang na ang UI ug OOP.
    well typedef/struct and class happens to have some common functionalities... but if you go further, you'll notice the big difference of using struct and class especially in OS & Compiler's stand point. C has a limited features yet extremely powerful...

  9. #19
    Quote Originally Posted by MarkCuering View Post
    well typedef/struct and class happens to have some common functionalities... but if you go further, you'll notice the big difference of using struct and class especially in OS & Compiler's stand point. C has a limited features yet extremely powerful...
    limited ang features sa C? sure uy. basin imong skills sa C ang limited bro?

    Quote Originally Posted by Linus Torvalds
    ...

    In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with.

    ...

    In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.
    source: http://thread.gmane.org/gmane.comp.v...43/focus=57918

    ako na gi-post kay implying man ka about c++ because you mentioned classes (c with classes - an early name of c++). wala mana nga feature sa c. although it's possible to implement the idea of classes in c, my point is you can do object-oriented programming without classes bro, depende ra jud na sa skills nimo as a programmer. OOP is conceptual, it's not just a certain feature of a particular programming language (classes), it's an idea, it's a way of thinking.

    ni-reply ra ko nimo sa previous post nako kay ingon man gud ka he should be doing OOP skills. basin magtuo ya tawn na siya nga dili na part sa OOP iyang implementation. by the way, it's called data objects bro. the basic types of variables in c are also called data objects, i.e. char, int, float etc. but it's the WAY he used typedef structs that made it OOP. bisan unsaon pa nato ug bali2x, part na siya sa concept. and he is already doing it (OOP) without resorting to class objects. for more information about this subject, you can read this book: object-oriented programming with ansi-c

    one more thing, the TS specifically stated that he needs help with c, not with c++, obviously classes are out so why bother mentioning it?

    Quote Originally Posted by marcdaven View Post
    Mga Bro, Good Day! Naa nasad ko diri karon to ask for help from your most gracious wisdom! Anyways, I have another C programming language problem. This time, it includes structures, pointer to pointer and linked lists....
    btw, unsa diay standpoint sa OS ug compiler about OOP? maka-nosebleed lagi na maglibog man pud ang mga newbie tungod sa ka-advanced nimo bro.

  10. #20

  11.    Advertisement

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

 
  1. cross fire error. please help me with this
    By orvillejoy in forum Video Games
    Replies: 6
    Last Post: 02-14-2011, 09:21 AM
  2. LTDIS1N.dll error please help!
    By vienabyam in forum Programming
    Replies: 1
    Last Post: 11-11-2010, 04:41 PM
  3. codec error..please help!!!
    By mikhailbogz in forum Software & Games (Old)
    Replies: 30
    Last Post: 10-14-2009, 11:42 PM
  4. Java Error... Please help!!!
    By happy_chique in forum Software & Games (Old)
    Replies: 3
    Last Post: 08-22-2008, 09:08 AM
  5. service error 6A00 for pixma ip4200..please help
    By zney25 in forum Computer Hardware
    Replies: 6
    Last Post: 07-10-2008, 10:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top