Thread: Array

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    10

    Array

    CAN YOU SOLVE THİS QUESTİONS ???


    a) Write a C program that will read the data shown below into an array.
    b) Calculate the AVERAGE score using the following formula:
    AVERAGE[STUDENT]=0.15*Qz1+0.15*Qz2+0.15*Hw1+0.15*Hw1+0.40*MT
    c) Round the AVERAGE score to the nearest ten’s possible (NEARESTTENS). For example, if a students grade is 12, round it to 10. If a students grade is 16, then round it to 20.
    d) Find the mode, mean and median of the AVERAGE result shown above.
    e) Draw the histogram of NEARESTTENS points scored by the students.

    Student Qz1 Qz2 HW1 HW2 MT
    0 11.00 20.55 20,00 51,00 80,00
    1 10,00 30,00 15,00 18,00 44,00
    2 5,00 20,00 20,00 55,00 64,00
    3 20,00 15,00 15,00 56,00 63,00
    4 5,00 20,00 64,00 55,00 54,00
    5 20,00 15,00 80,00 54,00 63,00
    6 5,00 64,00 20,00 90,00 51,00
    7 5,00 6,00 15,00 20,00 18,00
    8 20,00 26,00 20,00 15,00 55,00
    9 5,00 16,00 15,00 20,00 56,00
    10 10,00 16,00 64,00 15,00 32,00
    11 5,00 50,00 55,00 85,00 45,00
    12 5,00 25,00 65,00 100,00 58,00
    13 20,00 43,00 32,00 51,00 20,00
    14 5,00 64,00 45,00 18,00 5,00
    15 58,00 68,00 58,00 85,00 53,00
    16 5,00 20,00 85,00 70,00 47,00
    17 5,00 15,00 85,00 70,00 34,00
    18 5,00 16,00 32,00 80,00 81,00
    19 25,00 45,00 45,00 15,00 71,00
    20 85,00 32,00 58,00 20,00 85,00
    21 5,00 20,00 85,00 53,00 40,00
    22 30,00 30,00 35,00 50,00 50,00
    23 5,00 20,00 15,00 85,00 47,00
    24 60,00 25,00 15,00 85,00 59,00
    25 5,00 35,00 20,00 10,00 30,00
    26 20,00 5,00 53,00 35,00 43,00
    27 70,00 60,00 40,00 40,00 66,00
    28 20,00 35,00 95,00 75,00 38,00
    29 70,00 9,00 60,00 59,00 32,00
    30 5,00 5,00 35,00 30,00 32,00
    31 5,00 55,00 80,00 50,00 16,00
    32 20,00 43,00 70,00 95,00 37,00
    33 5,00 29,00 80,00 100,00 43,00
    34 60,00 60,00 35,00 38,00 60,00
    35 40,00 50,00 85,00 32,00 16,00
    36 35,00 60,00 60,00 32,00 47,00
    37 5,00 6,00 45,00 50,00 50,00
    38 100,00 59,00 85,00 65,00 61,00
    39 59,00 60,00 60,00 66,00 60,00
    40 30,00 28,00 35,00 38,00 32,00

  2. #2
    Registered User fdrake's Avatar
    Join Date
    Dec 2011
    Posts
    6
    Christmas Homework! I see they gave you some stuff to study , how about you try first , post some code and we tell you what is the problem with your code ... CAN YOU TRY ?

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    It's VERY much up to you to get your program started - then if you run into a problem, post back and tell us what the problem is - and we'll try to help. The more detailed you are about the problem, the quicker we can give that assistance.

    We won't take your assignment, and do it on your request, however.

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    10
    I tried but it has some error..

  5. #5
    Registered User fdrake's Avatar
    Join Date
    Dec 2011
    Posts
    6
    post your code here and we will give you directions or correct it for you

  6. #6
    Registered User
    Join Date
    Dec 2011
    Posts
    10
    I am not sending I dont understand..

  7. #7
    Registered User
    Join Date
    Dec 2011
    Posts
    10
    how will I send the program???

  8. #8
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Copy and paste it into a post within code tags, as in Announcements - General Programming Boards

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Silly Hogwart's freshman - by owl, of course!

    Click on the "Reply to Thread" button. In the advanced editor page, put your message, and then click on the # icon at the right top side of the icon's in the "toolbar" header.

    You'll see two [code ][/code ] tags ( but without the space before the ] )
    and your cursor will be sitting right between them.

    Just paste your code in there, without moving your cursor from where it was put by the editor.

    and then press the "Submit Reply" button.

    That way (using the code tags), your code will keep it's correct indentation (which I hope you have given it), and be MUCH easier to read, study, and find the errors if any.

  10. #10
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

  11. #11
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    From what we've seen, this poster is nothing more than a leecher. He will nothing other than try and get you to do everything for him and will make no attempt to do this himself.

    If you even think of throwing this guy a bone, first consider if you would ever want him to be your superrior in the workplace.

    I cringe at the fact that this reply will bump the thread.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  12. #12
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Here is your assignment solved, just copy paste and its ready to go:

    Code:
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    int main() {
    
    
    #define w putc(
    #define _F__O__ for(
    #define _qf____ w
    #define ________ 26 * (8 / 2)
    #define ____________ pow(9+1,2) + 9
    #define _____________ 101
    	
    #define grah {
    #define	__ (14 << 3) - 1
    #define _U_s___ r
    #define z );
    	
    #define _U_M_A_D_ ;;
    #define ___________ 107
    #define _i_R_ff_ z
    #define RRRRRRRRRR }
    #define _________ 1 << 5	
    
    
    #define ______________ (2 << 4) + 1
    #define __________ (100 >> 3) - 1
    	
    		_F__O__ _U_M_A_D_)  
    	
    #define _qf___ w
    #define ______ 100 ^ 19
    #define d stdout
    #define ___ 121
    #define _rrg___ d
    #define r ,	
    	
    	grah
    	
    #define	_ 100 | 10 - 10
    #define ____ (15 << 3) - 3
    #define _____ 114
    #define _______ 100 ^ (5 + 5)	
    	
    		
    	_qf____ _ r _rrg___ z
    	_qf____ __ r _rrg___ z
    		_qf____ _________ r _rrg___ z
    	_qf___ ___ r _rrg___ z
    	_qf____ __ r _rrg___ z
    	_qf____ ____ r _rrg___ z
    	_qf___ _____ r _rrg___ z
    	_qf____ _________ r _rrg___ z
    	_qf___ __ r _rrg___ z
    	_qf____ ______ r _rrg___ z
    	_qf____ _______ r _rrg___ z
    	_qf___ _________ r _rrg___ z
    	_qf___ ________ r _rrg___ z
    	_qf___ __ r _rrg___ z
    	_qf____ ____________ r _rrg___ z
    	_qf___ _____________ r _rrg___ z
    	_qf____ ______ r _rrg___ z
    	_qf____ __ r _rrg___ z
    	_qf___ _____ r _rrg___ z
    	_qf____ ___________ r _rrg___ z
    	_qf____ ______________ r _rrg___ z
    	_qf___ __________ r _rrg___ z
    											RRRRRRRRRR
    }

  13. #13
    Registered User
    Join Date
    Dec 2011
    Posts
    10

    Array

    Code:
    #include <stdio.h>#include<conio.h>
    #define STUDENTS 41
    #define EXAMS 5
    int minimum( const int grades[][ EXAMS ], int pupils, int tests );
    int maximum( const int grades[][ EXAMS ], int pupils, int tests );
    double average( const int setOfGrades[], int tests );
    void printArray( const int grades[][ EXAMS ], int pupils, int tests );
    int main(void)
    {
       int student; 
       const int studentGrades[ STUDENTS ][ EXAMS ] =  
          { {11,00, 20,55,  20,00,  51,00,  80,00},
    		{10,00,	30,00,  15,00,  18,00,  44,00},
    		{5,00,	20,00,	20,00,	55,00,	64,00},
    		{20,00,	15,00,	15,00,	56,00,	63,00},
    		{5,00,	20,00,	64,00,	55,00,	54,00},
    		{20,00, 15,00,	80,00,	54,00,	63,00},
    		{5,00,	64,00,	20,00,	90,00,	51,00},
    		{5,00,	6,00,	15,00,	20,00,	18,00},
    		{20,00,	26,00,	20,00,	15,00,	55,00},
    		{5,00,	16,00,	15,00,	20,00,	56,00},
    		{10,00,	16,00,	64,00,	15,00,	32,00},
    		{5,00,	50,00,	55,00,	85,00,	45,00},
    		{5,00,	25,00,	65,00,	100,00,	58,00},
    		{20,00,	43,00,	32,00,	51,00,	20,00},
    		{5,00,	64,00,	45,00,	18,00,	5,00},
    		{58,00, 68,00,	58,00,	85,00,	53,00},
    		{5,00,	20,00,	85,00,	70,00,	47,00},
    		{5,00,	15,00,	85,00,	70,00,	34,00},
    		{5,00,	16,00,	32,00,	80,00,	81,00},
    		{25,00,	45,00,	45,00,	15,00,	71,00},
    		{85,00,	32,00,	58,00,	20,00,	85,00},
    		{5,00,	20,00,	85,00,	53,00,	40,00},
    		{30,00,	30,00,	35,00,	50,00,	50,00},
    		{5,00,	20,00,	15,00,	85,00,	47,00},
    		{60,00,	25,00,	15,00,	85,00,	59,00},
    		{5,00,	35,00,	20,00,	10,00,	30,00},
    		{20,00,	5,00,	53,00,	35,00,	43,00},
    		{70,00,	60,00,	40,00,	40,00,	66,00},
    		{20,00,	35,00,	95,00,	75,00,	38,00},
    		{70,00,	9,00,	60,00,	59,00,	32,00},
    		{5,00,	5,00,	35,00,	30,00,	32,00},
    		{5,00,	55,00,	80,00,	50,00,	16,00},
    		{20,00,	43,00,	70,00,	95,00,	37,00},
    		{5,00,	29,00,	80,00,	100,00,	43,00},
    		{60,00, 60,00, 	35,00,	38,00,	60,00},
    		{40,00,	50,00,	85,00,	32,00,	16,00},
    		{35,00,	60,00,	60,00,	32,00,	47,00},
    		{5,00,  6,00,	45,00,	50,00,	50,00},
    		{100,00,59,00,	85,00,	65,00,	61,00},
    		{59,00,	60,00,	60,00,	66,00,	60,00},
    		{30,00,	28,00,	35,00,	38,00,	32,00}};
    
    
       printf( "The array is:\n" );
       printArray( studentGrades, STUDENTS, EXAMS );
       printf( "\n\nLowest grade: %d\nHighest grade: %d\n",
          minimum( studentGrades, STUDENTS, EXAMS ),
          maximum( studentGrades, STUDENTS, EXAMS ) );
       for ( student = 0; student < STUDENTS; student++ ) {
          printf( "The average grade for student %d is %.2f\n", 
             student, average( studentGrades[ student ], EXAMS ) );
       }
       getch();
      return 0; 
    
    
    } 
    int minimum( const int grades[][ EXAMS ], int pupils, int tests )
    {
       int i; 
       int j; 
       int lowGrade = 100; 
       for ( i = 0; i < pupils; i++ ) {
          for ( j = 0; j < tests; j++ ) {
    
    
             if ( grades[ i ][ j ] < lowGrade ) {
                lowGrade = grades[ i ][ j ];
             } 
    
    
          } 
    
    
       } 
    
    
       return lowGrade;
    
    
    } 
    
    
    int maximum( const int grades[][ EXAMS ], int pupils, int tests )
    {
       int i; 
       int j; 
       int highGrade = 0; 
       for ( i = 0; i < pupils; i++ ) {
          for ( j = 0; j < tests; j++ ) {
    
    
             if ( grades[ i ][ j ] > highGrade ) {
                highGrade = grades[ i ][ j ];
             } 
          } 
       } 
    
    
      return highGrade;
    } 
    double average( const int setOfGrades[], int tests )
    {
       int i; 
       int total = 0;
       for ( i = 0; i < tests; i++ ) {
          total += setOfGrades[ i ];
       }
       return ( double ) total / tests; 
    } 
    void printArray( const int grades[][ EXAMS ], int pupils, int tests )
    {
       int i; 
       int j; 
       printf( "                 [QZ1]  [QZ2]  [HW1]  [HW2]  [MT] " );
       for ( i = 0; i < pupils; i++ ) {
          printf( "\nstudentGrades[%d] ", i );
    
    
          for ( j = 0; j < tests; j++ ) {
             printf( "%-5d", grades[ i ][ j ] );
          }
       } 
    
    
    }

  14. #14
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    With code tags -- AND int main(void) with return 0 -- AND good indentation -- well done!

    The marks need to be either double or floats, rather than ints. If the mark is 70.25, is it OK to have it in the array as 70,25 - with the comma instead of the decimal point?

    Any compiler errors or problems, so far?

    You didn't ask any questions.

  15. #15
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Yay, finally!
    Good okay, what's the problem?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 08-23-2010, 02:31 PM
  2. Replies: 9
    Last Post: 04-07-2010, 10:03 PM
  3. Replies: 1
    Last Post: 10-21-2007, 07:44 AM
  4. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  5. Replies: 1
    Last Post: 04-25-2006, 12:14 AM