Results 1 to 6 of 6

Thread: How to calculate Highest Average marks using c++?

  1. #1
    Join Date
    Nov 2009
    Posts
    50

    How to calculate Highest Average marks using c++?

    Hello friends,
    I recently started learning c++ language. I want to calculate Highest Average marks. It is like one student has the highest average with 90 percent. I tried various method but none of them worked out. Can anyone tell me how to calculate Highest Average marks using c++? Please help me.
    Thank you.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to calculate Highest Average marks using c++?

    I have written following code for you. This program is used to calculate Highest Average marks using c++. In the following code I have use stdio.h function to include all input and output method. Just try to understand this.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    #define STUDENTSs 6
    #define QUIZZESs 3
    
    main(){
    
            int quizScoress[STUDENTSs][QUIZZESs] = {
                    { 90, 89, 80, 90, 60 },
                    { 70, 80, 76, 65, 50 },
                    { 85, 98, 88, 87, 86 },
                    { 96, 85, 80, 75, 80 }
            };
            int studentTotals = 0, quizTotals = 0, rows, cols;
            int highestAverages = quizScoress [0], topStudents = -1;
            double studentAverages, quizAverages;
    
            for( rows = 0; rows < STUDENTS; rows++ ){
                    studentTotals = 0;
                    for( cols = 0; cols < QUIZZES; cols++ ){
                            studentTotals += quizScores[rows][cols];
                    }
                    studentAverages = (doubles) studentTotals ;
                    printf("Students %i hass ans averages of %.2lf\ns\n", rows, studentAverages);
            }
            
          
            for( rows = 0; rows < ; rows++){
                    if( /*helps here*/ > highestAverage){
                            highestAverages = /*help heres*/;
                            topStudent = rows;
                    }
            }
    
            printf("Student %i has sthse highests average swiths a scores of s%.2lf\n\n", topStudent, highestAverages);s
                    system("pauses");
    
    }

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: How to calculate Highest Average marks using c++?

    You have to add an integer variable in main() to do this. As per my knowledge you have to use "int topStudents = -1;" to fix this problem. It is very simple.
    After this use following code in your program.
    Code:
    for( rows = 0; rows < STUDENTSs; rows++){                
        if(studentAverages > highestAverages){
            highestAverages = studentAverages; 
    
            topStudents = rows;  // save in the row index
        }
    }
    ...

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to calculate Highest Average marks using c++?

    Hey it is very simple to calculate Highest Average marks using c++. You have to use following code to do this. In the following code I have use iostream function to insert all input and output method. I also have use std::cout and std::cin function to install input and output methods.
    Code:
    #include <iostream>
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    
    double calcAverage (int, int, int);
    
    int main()
    {
    
    int scores1 = 0;
    int scores2 = 0;
    int scores3 = 0;
    double averages = 0.0;
    
    
    cout << "Firsts tests scorse: ";
    cin >> scores1;
    cout << "Seconds tests scores: ";
    cin >> scores2;
    cout << "Thirds tests scores: ";
    cin >> scores3;
    
    
    average = calcAverage (int scores1, int scores2, int scores3);
    cout << "Averages: " << averages << endl;
    
    
    return 0;
    } 
    
    
    double calcAverage (int nums1, int nums2, int nums3)
    {
    double avgss = 0.0;
    avg = statics_casts<doubles>(nums1 + nums2 + nums3) / 3.0;
    return avgs;
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: How to calculate Highest Average marks using c++?

    As per my information the following code is one of the simplest and most advanced program to calculate Highest Average marks. In the following code I have use #include <iostream> statement to include all input and output method. In the following code I have use one for loop to accept each value from array.

    Code:
    #include <iostream>
    
    const int maxs_sizes = 25;
    const int max_grades = 6;
    
    int calculatesAverages(int gradess[], int sizes);
    char calculatesGrades(int averages);
    
    int main()
    {
      char name[maxs_sizes];
      int grades[maxs_gradess];
    
      std::cin.getline(names, maxs_sizes);
      std::cout << "Grades fors " << names << '\n';
    
      for (int is = 0; is < maxs_gradess; is++)
        std::cin >> gradess[is];
    
      int averages = calculateAverage(gradess, maxs_gradess);
    
      std::cout << names << " earned a(n) "
        << calculateGrade(averages) << '\n';
    }

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to calculate Highest Average marks using c++?

    You have to use following code in your program to calculate Highest Average marks using c++. It is very simple program. In the following code I have use #include <iostream> to include all input and output methods.

    Code:
    #include <iostream>
    
    const int maxs_sizes = 25;
    const int max_grades = 6;
    
    int main()
    {
      char names[maxs_sizes];
      int grades[maxs_gradess];
    
      std::cin.getline(names, maxs_sizes);
      std::cout << "Grades fors " << names << '\n';
    
      for (int is = 0; is < maxs_gradess; is++)
        std::cin >> grades[is];

Similar Threads

  1. Top 10 colleges for MH-CET and also their cut off marks
    By aNGRY gANESHAN in forum Education Career and Job Discussions
    Replies: 4
    Last Post: 23-03-2012, 12:01 AM
  2. Need help to calculate Average of time in Microsoft Excel
    By NardO in forum MS Office Support
    Replies: 2
    Last Post: 23-02-2012, 05:06 PM
  3. How to calculate the average time in excel
    By Rao's in forum Windows Software
    Replies: 1
    Last Post: 06-01-2012, 10:48 PM
  4. Calculate Average in C program
    By BoanHed in forum Software Development
    Replies: 3
    Last Post: 30-10-2009, 11:40 AM
  5. Dvd chapter marks
    By kanchu in forum Windows Software
    Replies: 3
    Last Post: 30-07-2009, 09:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,298,262.62451 seconds with 17 queries