Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:00:56+00:00 2026-06-15T16:00:56+00:00

Here is the code: void option5 (StudentRecord student[], int n) { double gpaThreshold; char

  • 0

Here is the code:

void option5 (StudentRecord student[], int n)

{
   double gpaThreshold;
   char enteredMajor;
   int i;

   cout << "Enter a GPA threshold: ";
   cin >> gpaThreshold;
   cin.ignore(80, '\n');

   cout << "Enter a Major: ";
   cin >> enteredMajor;
   cin.ignore(80, '\n');

   enteredMajor = toupper(enteredMajor);

   for (i = 0; i < n; i++)
   {
      if (student[i].gpa >= gpaThreshold && student[i].major == enteredMajor)
      {
         if (i % 10 == 0)
         {
            cin.ignore();
         }
         cout << setw(3) << right << i+1 << ". "  
         << setw(20) << left << student[i].lastName 
         << setw(20) << left << student[i].firstName 
         << setw(8) << left << student[i].major 
         << fixed << setprecision(2) << setw(8) << left << student[i].earnedHours 
         << fixed << setprecision(2) << setw(6) << left << student[i].gpa << endl;
      }
   }
}

StudentRecord is a struct, and the only integer on that line is ‘i’, whereas the pointer (I would have to assume) is .major.

I’m wanting to compare an entered major, with the “Major” values in the array.
E.G. I type in Chem
-turns to CHEM
-fetches all students under that major (and threshold of GPA)
-displays the above statement (all students of ‘X’ major)

Any suggestions? Help? Comments? Positive/Negative Feedback?

EDIT: Here is the struct:

struct StudentRecord
{
   char     lastName [16];  // field definitions of the structure
   char     firstName[16];
   char     hometown [16];
   char     major[5];
   int      studentNumber;
   double   balance;
   int      earnedHours;
   double   gpa;
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:00:57+00:00Added an answer on June 15, 2026 at 4:00 pm

    Consider this fragment:

    student[i].major == enteredMajor
    

    student[i].major is a char[5], which devolves into a char* in this context. This is a pointer type.

    enteredMajor is a char. This is an integral type.

    You cannot compare these types.

    Perhaps you meant to decalre enteredMajor thus:

    char enteredMajor[5];
    

    and compare them like this:

    strcmp(student[i].major, enteredMajor) == 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: void subroutine(const char *message) { printf(message); } And here is
Here is the code: public static void main(String args[]) { int i=0; int m=0;
Here is my code: - (void)loadView { //hard coded array of content for each
Why does the titlebar overlap the pixels of JPanel. Here some code: protected void
Here is my code: partial void OnisApprovedChanging(bool value) { this.dateApproved = DateTime.Now; } 'dateApproved'
i can't set title to Action bar sherlock. Here is my code: public void
Here's the code in AlertTableView: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSInteger index = 12345; NSLog(@AlertTableView:
Here is my code : public static void main(String[] args) { // System.setProperty( //
Here’s my code behind: protected void gvviewapproval_RowUpdated(object sender, GridViewUpdatedEventArgs e) { using (SqlConnection cn
I have a problem with this code right here: - (void)fetchedData:(NSData *)responseData { //parse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.