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 8480289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:15:19+00:00 2026-06-10T19:15:19+00:00

I’m new to C++ and am not sure what’s wrong. This is a task

  • 0

I’m new to C++ and am not sure what’s wrong. This is a task I have been given in my programmging course at uni which is meant to take user input of a vector of grades and determine whether the grade is a passing one. When I compile I end up getting an error stating q1.cpp:30:21: error: could not convert ‘y’ from ‘int’ to ‘std::vector’
Not overly sure why. Sorry about the bad formatting.

I’ve added the code but not sure how to wrap it.

#include <vector>
#include <cstdlib>
#include <iostream>

using namespace std;

int calcNumberOfPasses(vector<int> grades){
int x;
    for (int i=0; i<grades.size(); i++){
        cin >>grades[i];
    }
    cin >> x;
}



int main() {
    int y;
    vector<int> nGrade;
    nGrade.push_back(y);
    cout << "Enter how many grades you want to enter";
    for (int i=0; i<nGrade.size();i++){
        cin >> nGrade[i];
    }
    cin >> y;
    if (y>=50){
        cout << "this is a passing grade";
    }
    calcNumberOfPasses(y);
}
  • 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-10T19:15:20+00:00Added an answer on June 10, 2026 at 7:15 pm

    The function calcNumberOfPasses is expecting a parameter of type vector<int>, you are passing it a parameter of type int. That much you can work out from the error message.

    You are copying an undefined value into the vector on this line:

    nGrade.push_back(y); // y hasn't been initialised yet, you probably want to remove this line.
    

    Following that you are looping over the size of the grades vector, which hasn’t been initialised yet.

    Chances are, you want to do calcNumberOfPasses(nGrades);.

    As an aside, you should use a reference to the vector, to avoid copying it.

    In summary, I would through all of this code away and start again. No offence!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from
I have an array which has BIG numbers and small numbers in it. I

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.