Article View: alt.comp.lang.learn.c-c++
Article #95Re: Problematic Program
From: Neil Butterworth
Date: Sun, 20 Oct 2002 21:08
Date: Sun, 20 Oct 2002 21:08
51 lines
2674 bytes
2674 bytes
"CM" <mckenzie992@comcast.net> wrote in message
news:ESudnc40b4i4hS6gXTWcow@comcast.com...
> Hello everyone,
> I thought I had finished a c++ V2
What does "V2" mean?
> program when I ended up having several
> unexpected compilation errors that I am not sure how to fix.
All compilation errors are unexpected.
The jist of
> the program is to take 5 student names, 5 ids for those students, 3 grades
> for each student and then calculate gpa displaying in a table format:
> Name Name 1 Name 2
> Id 999 222
> Grade 1 90 80
> Grade 2 90 80
> Grade 3
> GPA
> etc.
>
> I have included what I have so far, was hoping someone could help to find
my
> mistake.
> #include <string>
> #include <iostream>
> using namespace std;
> #include <stdlib.h>
> void main()
> {
> int noOfGrades=3;
> int noOfStudents=5;
> char names[noOfStudents]; // array of names (strings)
> char ID[noOfStudents]; // array of ID's (strings)
> double Grades[noOfStudents][noOfGrades]; // array of 5 arrays each of 3
Your basic problem is here - the dimensions of automatic arrays in C++ must
be constants known at compile time. One way of fixing your code would be to
declare your dimension sizes as:
const int noOfGrades=3;
const int noOfStudents=5;
This will fix some, but not all. problems in your code. Patch these fixes
in, try to fix the remaining problems and if you can't post here again. But
remember, we don't do homework for you.
NeilB
Technical Details
Message-ID:
<3db31a56$1_1@mk-nntp-1.news.uk.worldonline.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!kibo.news.demon.net!demon!mk-nntp-1.news.uk.worldonline.com!ppp-1-79.lond-a-2.access.uk.tiscali.comReferences:
<ESudnc40b4i4hS6gXTWcow@comcast.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,635d58b7486c58ea X-Google-Attributes: gid109fba,public X-Google-Thread: 10d4ba,635d58b7486c58ea X-Google-Attributes: gid10d4ba,public X-Google-Thread: 114592,635d58b7486c58ea X-Google-Attributes: gid114592,public X-Google-ArrivalTime: 2002-10-20 14:04:24 PST From: "Neil Butterworth" <neil_butterworth@lineone.net> Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++ References: <ESudnc40b4i4hS6gXTWcow@comcast.com> Subject: Re: Problematic Program Date: Sun, 20 Oct 2002 22:08:19 +0100 Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: ppp-1-79.lond-a-2.access.uk.tiscali.com Message-ID: <3db31a56$1_1@mk-nntp-1.news.uk.worldonline.com> X-Trace: 20 Oct 2002 22:04:22 +0100, ppp-1-79.lond-a-2.access.uk.tiscali.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!kibo.news.demon.net!demon!mk-nntp-1.news.uk.worldonline.com!ppp-1-79.lond-a-2.access.uk.tiscali.com