Thread: help me with ma c programme..

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    9

    Question help me with ma c programme..

    ## design and write a programme to tabulate the results of 10 students of 4 subjects using C programme. this programme will take Name, ID, marks as individual input.
    calculate the results under following conditions:

    a)students who have failed in 2 0r more subjects, will not be promoted in the next level.

    b) students who obtained an average marks of
    i) more or equal 70% will get Grade A
    ii) more or equal 60% but less than 70% will get Grade B
    iii) more or equal 50% but less than 60% will get Grade C
    iv) more or equal 45% but less than 50% will get Grade D
    v) more or equal 40% but less than 45% will get Grade E
    vi) less than 40% will get Grade F

    c) the programme will be able to sort the students in order of marks obtained excluding those failed in 2 or more subjects.

    the rsult of each students is needed to be saved in a file and finally to be printed in a tabular format.

  2. #2
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    i m stuck in da filing n sorting phase ..pls help me,,,

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    And your question is...?

    >> i m stuck in da filing n sorting phase ..pls help me,,,

    So post the code you have written so far.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by eddie19 View Post
    i m stuck in da filing n sorting phase ..pls help me,,,
    You don't need to do any filin' and sortin' -- ur suppose to rite a program 4 that.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    One Level Below Beginner
    Join Date
    Jul 2009
    Location
    Corner of Nowhere and Yonder
    Posts
    19
    I am guessing you are falling in the "vi" category of your class?

  6. #6
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by Banned View Post
    I am guessing you are falling in the "vi" category of your class?
    what's "vi" category??

  7. #7
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by MK27 View Post
    You don't need to do any filin' and sortin' -- ur suppose to rite a program 4 that.
    may be dat's wha i m trin to do...
    but i m stuck in part c

  8. #8
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by eddie19 View Post
    what's "vi" category??
    The clock is ticking here, eddie19. If you get it.

    Quote Originally Posted by eddie19 View Post
    vi) less than 40% will get Grade F
    Quote Originally Posted by eddie19 View Post
    may be dat's wha i m trin to do...
    but i m stuck in part c
    No one is going to write it for you. You will have to identify a "problem" and ask a "related question".
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  9. #9
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by Sebastiani View Post
    And your question is...?

    >> i m stuck in da filing n sorting phase ..pls help me,,,

    So post the code you have written so far.
    my question is abt part C..
    how will i connect the results in a file list...
    i m talkin abt *fp thingy
    Code:
    #include<stdio.h>
    #include<math.h>
    
    main()
    {
          FILE *fp, *ff,*fs; 
        
          char name[20],pass,fail,student_file,grade;
          int n,m,i,j,roll_number,marks,count,total_mark;
          float average;
          
          printf("This programme is able to calculate students-");
          printf(" total mark,average & grade\n\n");
          printf("\n");
          
        
          
          printf(" Contents of this database will have a pass and a fail file\n\n\n");
          fs=fopen("student_file","w");
          
          
          
          printf("Enter total number of students and subjects\n");
          scanf("%d%d",&n,&m);
          printf("\n");
          for(i=1;i<=n;i++)
           {
                      
                      count=0;
                      printf("Enter roll_number:");
                      scanf("%d",&roll_number);
                      putw(roll_number,fs);
                      printf("\n");
                      printf("Enter Student's Name:");
                      scanf("%s",&name);
                      putw(roll_number,fs);
                      printf("\n");
                      total_mark=0;
                      printf("\n Enter marks of %d subjects for Roll no%d \n",m,roll_number);
                      for(j=1;j<=m;j++)
                      {
                          scanf("%d",&marks);
                          if(marks<40)
                              {
                                   count=count+1;
                                   if (count>=2)
                                       {
                                             printf("\n$* Not to be promoted in the Next Level *$\n\n");
                                             {
                                                          ff=fopen("fail", "w");
                                                          putw(roll_number,ff);
                                                          fclose(ff);
                                             }
                                             }
                                             }
                                             total_mark=total_mark+marks;
                                             }
                                             printf("TOTAL MARK:_  %d\n",total_mark);
                                             average=total_mark/m;
                                             printf("Average:_%f\n\n",average);
                                             
                                             {
                                             if (average>=70 & count<=1)
                                             printf("RESULT:- GRADE A\n\n",grade);
                                             
                                                              
                                                              
                                                              
                                              if (average>=60 & average<70 & count<=1)
                                             printf("RESULT:- GRADE B\n\n",grade);
                                             
                                                              
                                                            
                                             
                                             
                                              if (average>=50 & average<60 & count<=1)
                                             printf("RESULT:- GRADE C\n\n",grade);
                                             
                                                              
                                                            
                                             
                                              if (average>=45 & average<50 & count<=1)
                                             printf("RESULT:- GRADE D\n\n",grade);
                                             
                                                              
                                                             
                                             
                                             if (average>=40 & average<45 & count<=1)
                                             printf("RESULT:- GRADE E\n\n",grade);
                                             
                                                             
                                                            
                                             
                                             }
                                              fp=fopen("pass", "w");
                                                              
                                                              putw(roll_number,fp);
                                                              fclose(fp);
                                                              
                                              if (average<40 & count<=1)
                                            {
                                                   printf("RESULT:- **FAIL**\n\n",grade);
                                                   
                                                                   
                                                                    fp=fopen("fail", "w");
                                                              
                                                              putw(roll_number,ff);
                                                              fclose(ff);
                                                  
                                             }
                                             }
                                             
                                             fclose(fs);
                                              printf("\n\n ^^ students passed ^^\n\n");
                                            
                                                          {
                                                               fp=fopen("pass","r");
                                                               while((roll_number=getw(fp))!=EOF) 
                                                             
                                                               printf ("%4d",roll_number);
                                                               fclose(fp);
                                                               }
                                             
                                             
                                            
                                            
                                             
                                             getch();
                                             }
    Last edited by Salem; 08-12-2009 at 12:11 AM. Reason: Added [code][/code] tags, learn to use them yourself

  10. #10
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by MK27 View Post
    The clock is ticking here, eddie19. If you get it.





    No one is going to write it for you. You will have to identify a "problem" and ask a "related question".
    i m not sayin ny1 to rite da whole thing...
    i just need a direction...
    as i did almost 60% of it
    dis is ma 1st time doin C prog...#
    dat's y i m not quite good at it..

  11. #11
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by eddie19 View Post
    dis is ma 1st time doin C prog...#
    And programming boards are a great place to look for help, but much more so if you familiarize yourself with a few elementary principles when using them:

    Indent and use code tags:

    << !! Posting Code? Read this First !! >>

    Make an effort when you communicate:

    How To Ask Questions The Smart Way
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  12. #12
    One Level Below Beginner
    Join Date
    Jul 2009
    Location
    Corner of Nowhere and Yonder
    Posts
    19
    Quote Originally Posted by MK27 View Post
    Make an effort when you communicate:
    No offense, but that is a nice way of saying "use proper grammar."

    Try not to type in the same manner that you talk.

    Using the "word" dis instead of this on some forums is considered rude, and insults your intelligence.

  13. #13
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Banned View Post
    No offense, but that is a nice way of saying "use proper grammar."
    ABSOLUTELY NOT! I don't give a f..k about your grammar, altho if I can't understand you because of it then I won't have anything to say.

    I really should make up my own "how to ask smart questions" but I think it gets the point across anyway. IMO, the Original Poster needs to isolate an issue s/he is having problems with and try to demonstrate the problem. Just posting a bunch of code and making vague "out loud thoughts" that require the people you are asking for help interpret properly.

    I'm not saying this because I want to enforce rules either. I am working, but I like occasionally answering questions and AFAICT I do help people fairly often. But the more time it is going to take me to get to the bottom of someone's problem, the less likely I am to bother with it -- especially if I think that person could be more specific and "focus" better. I don't come on here when I have a problem and post the entire code of my latest program and say "I think the problem is in the client process". On the other hand, if someone has asked a clear and specific question, I will sometimes go to lengths to provide insight even if I do not know the answer off the top of my head. I regularly spend hours doing that, if you catch me in the right mood AND KNOW HOW TO ASK SMART QUESTIONS.

    If you can write a program, you should be able to isolate where you are unsure of yourself. Other dan dat U kan tlk wat evr, that is not a significant issue 4 me. I agree with the earlier implication that this particular poster is like in a lower percentile with regard to savy, and that in my experience, for what that is worth, s/he will have an easier time getting advice from me and others, here and everywhere, if s/he takes this observation to heart (hopefully poor eddie19 can find dis part o' da body )
    Last edited by MK27; 08-11-2009 at 08:49 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  14. #14
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by MK27 View Post
    ABSOLUTELY NOT! I don't give a f..k about your grammar, altho if I can't understand you because of it then I won't have anything to say.

    I really should make up my own "how to ask smart questions" but I think it gets the point across anyway. IMO, the Original Poster needs to isolate an issue s/he is having problems with and try to demonstrate the problem. Just posting a bunch of code and making vague "out loud thoughts" that require the people you are asking for help interpret properly.

    I'm not saying this because I want to enforce rules either. I am working, but I like occasionally answering questions and AFAICT I do help people fairly often. But the more time it is going to take me to get to the bottom of someone's problem, the less likely I am to bother with it -- especially if I think that person could be more specific and "focus" better. I don't come on here when I have a problem and post the entire code of my latest program and say "I think the problem is in the client process". On the other hand, if someone has asked a clear and specific question, I will sometimes go to lengths to provide insight even if I do not know the answer off the top of my head. I regularly spend hours doing that, if you catch me in the right mood AND KNOW HOW TO ASK SMART QUESTIONS.

    If you can write a program, you should be able to isolate where you are unsure of yourself. Other dan dat U kan tlk wat evr, that is not a significant issue 4 me. I agree with the earlier implication that this particular poster is like in a lower percentile with regard to savy, and that in my experience, for what that is worth, s/he will have an easier time getting advice from me and others, here and everywhere, if s/he takes this observation to heart (hopefully poor eddie19 can find dis part o' da body )
    Well said.

  15. #15
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Just reverse sort the array by grade, and don't write anyone who failed down in the printing phase.

    Since we're talking about grammar now, you can do the first clause with qsort, and the other with a loop and an if statement.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to view the programme before it disappears
    By yousuf in forum C Programming
    Replies: 2
    Last Post: 03-22-2008, 08:12 AM
  2. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  3. import xml file to visual c++
    By Psico_Mind in forum C++ Programming
    Replies: 4
    Last Post: 05-22-2005, 10:09 AM
  4. Gui Programme does'nt Compiles from DOS
    By Shadowhunt in forum C++ Programming
    Replies: 1
    Last Post: 06-06-2003, 08:05 AM
  5. Simple C++ GUI programme does'nt run from dos
    By Shadowhunt in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2003, 05:30 AM

Tags for this Thread