Results 1 to 2 of 2

Thread: Simple help

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Simple help

    there are a few layout problems eg. numbers are
    stuck to
    names and they are numbered from 0 to 9 rather than 1 to 10

    #include <iostream>
    #include <string>

    using namespace std;

    // Function prototype
    void showStudentNames(string *,string *);

    // Define the constant
    const int NUM_STUDENTS = 11;

    int main()
    {
    string firstnames[] = {"Rudolf","David","Supong","Morrakot","Marsan","Laksmana","Todd","Steven","Dianne","Nittaya"};
    string lastnames[] = {"Jones","Rhodes","Mangunwijaya","Jiengpattanakit","Khoangam","Sankey","Gowans","Veldman","Straughan ","Djuniarti"};
    showStudentNames(firstnames,lastnames);
    getchar();
    return 0;
    }
    void showStudentNames(string *first,string *last)
    {
    for(int i=0;i<NUM_STUDENTS;i++)
    cout<<i<<' '<<last[i]<<", "<<first[i]<<endl;
    }

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Simple help

    You want to display numbers from 1 to 10 rather than 0 to 9:
    Code:
    void showStudentNames(string *first,string *last)
    {
    for(int i=1;i<NUM_STUDENTS;i++) //NUM_STUDENTS = 11
    cout<<i<<' '<<last[i-1]<<", "<<first[i-1]<<endl;
    }
    Show Appreciation. Rate Posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width