Results 1 to 7 of 7

Thread: string arrays

  1. #1

    string arrays

    hello everyone,i'm writing a program with two void functions using string arrays.the first one should input 15 names with 15 marks for students and the other one should display whether 15 students have passed or failed.

    this is what i did below and i hope someone will help me because i can't even sleep because of this program


    #include<iostream>
    #include<string>
    using namespace std;
    using std::getline;
    void getInput(string[] ,int[]);
    void displayResults(string&,int&);


    int main()
    {

    int MarkP[15];

    string NameP[15];

    for(int x=0;x<15;x++)
    {
    getInput(NameP[x],MarkP[x]);
    }

    for(int j=0;j<15;j++)
    {
    displayResults(NameP[j],MarkP[j]);
    }

    return 0;
    }
    void getInput(string NameP[],int MarkP[])

    {


    cout<<"Enter the Name of the student\n";
    cout<<"Name\t\tMarks\n";

    getline(cin,NameP);
    cin.ignore();
    cout << "\t\t";
    cin>>MarkP;
    cin.ignore();

    }
    void displayResults(string& NameP,int& MarkP)
    {
    if(MarkP>=0&&MarkP>=39)
    {
    cout<<"\n failed";
    }




    }

  2. #2
    Forum Techie A_old's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta
    Posts
    10,663
    So what is it that you don't understand, exactly (What's your question?)?

  3. #3
    i don't get the required results i need.firstly my program has to store the names and marks after that it has to display the results whether they passed or failed

  4. #4
    no. no, No. NO, NO... NO! stevebakh's Avatar
    Join Date
    Aug 2002
    Posts
    3,228
    It sounds very typical of the kind of mini-program one makes in class. Generally, you have the marks and then you calculate whether it's a pass or fail. Simply put, there will be pass level. So, an array element with a mark of, say, 40 or over, is a pass. Under 40? A fail.

    So you need to know the minimum pass mark.

  5. #5
    Forum Techie A_old's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta
    Posts
    10,663
    Quote Originally Posted by stevebakh View Post
    It sounds very typical of the kind of mini-program one makes in class. Generally, you have the marks and then you calculate whether it's a pass or fail. Simply put, there will be pass level. So, an array element with a mark of, say, 40 or over, is a pass. Under 40? A fail.

    So you need to know the minimum pass mark.
    I think he's asking us to give him the fixed, complete code (which I'm not willing to do).

  6. #6
    The ghost in the machine striker8000's Avatar
    Join Date
    Mar 2004
    Location
    lost in time
    Posts
    881
    There's also the point that he's trying to do it the long way.
    still folding away, haven't been on as much lately

  7. #7
    Forum Techie A_old's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta
    Posts
    10,663
    Quote Originally Posted by striker8000 View Post
    There's also the point that he's trying to do it the long way.
    it's probably starting code given by the instructor, meant to teach something specific

Similar Threads

  1. Were can I find what slot I have for vid card
    By agustintorre in forum Hardware & Overclocking
    Replies: 51
    Last Post: 02-10-07, 04:59 AM
  2. Tweaking Firefox 2.0
    By Sava700 in forum Software Forum
    Replies: 7
    Last Post: 12-21-06, 09:41 AM
  3. Firefox 2.0 Tweak
    By FuzzyDnkn in forum Software Forum
    Replies: 8
    Last Post: 12-21-06, 09:39 AM
  4. Replies: 1
    Last Post: 01-28-06, 11:28 PM
  5. String Theory
    By golfnintendoboy in forum General Discussion Board
    Replies: 10
    Last Post: 09-28-05, 03:49 AM

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
  •