Welcome Guest ( Log In | Click here to Register a free account now! )
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.| Important Announcement: The winners of the BC Million Post contest have been announced. You can read who the winners are at this post. - BleepingComputer Management |
![]() ![]() |
Apr 17 2005, 10:25 PM
Post
#1
|
|
|
New Member ![]() Group: Members Posts: 3 Joined: 17-April 05 Member No.: 17,323 |
// cs101,TTH // calculate my average // This program will calculate my curent grade average #include <iostream.h> const int NUMSCORES = 3; int main() { int Firstscore; //holds first score int secondscore; //holds second score int thirdscore; //holds third score int totals_scores ; //holds input values of total scores cout << "NUMSCORES=3\n"; cout << "\t Grade Averages Calculator\n"; //output a title cout << "\n"; //output blank line cout << "Enter firstscore (whole number between 0 and 100)\n"; cin >> " total_scores=(firstscore + secondscore + thirdscore)/3"; cout << "Enter secondscore (whole number between 0 and 100)\n"; cin >>" total_scores=(firstscore + secondscore + thirdscore)/3"; "myprog.C" 29 lines, 970 characters chicoma [48]-% CC myprog.C cc-1020 CC: ERROR File = myprog.C, Line = 27 The identifier "total_scores" is undefined. cout << total_scores <<" thirdscore << secondscore << firstscore\n"; ^ cc-1174 CC: WARNING File = myprog.C, Line = 12 The variable "Firstscore" was declared but never referenced. int Firstscore; //holds first score ^ cc-1174 CC: WARNING File = myprog.C, Line = 13 The variable "secondscore" was declared but never referenced. int secondscore; //holds second score ^ cc-1174 CC: WARNING File = myprog.C, Line = 14 The variable "thirdscore" was declared but never referenced. int thirdscore; //holds third score ^ cc-1174 CC: WARNING File = myprog.C, Line = 15 The variable "totals_scores" was declared but never referenced. int totals_scores ; //holds input values of total scores ^ cc-1174 CC: WARNING File = myprog.C, Line = 8 The variable "NUMSCORES" was declared but never referenced. const int NUMSCORES = 3; ^ 1 error detected in the compilation of "myprog.C". chicoma [49]-% chicoma [49]-% |
|
|
|
Apr 17 2005, 10:56 PM
Post
#2
|
|
|
New Member ![]() Group: Members Posts: 3 Joined: 17-April 05 Member No.: 17,323 |
Any solutions can be sent to .
Mod edit: Email address removed for member's security. jgweed This post has been edited by jgweed: Apr 17 2005, 11:03 PM |
|
|
|
May 16 2005, 04:16 AM
Post
#3
|
|
|
Forum Regular ![]() ![]() ![]() Group: Members Posts: 172 Joined: 6-January 05 Member No.: 8,797 |
i noticed no replies, are you still working on this?
-------------------- ![]() Special thanks to efizzer for the signature |
|
|
|
May 19 2005, 03:24 AM
Post
#4
|
|
|
New Member ![]() Group: Members Posts: 11 Joined: 18-March 05 Member No.: 14,736 |
I find the first error in your program.
"The identifier "total_scores" is undefined."Here the "total_scores" is not defined in your program.I know your mean for the variable is "totals_scores", but "total_scores" is not equal to "totals_scores".I think it's a written faulty. |
|
|
|
Jun 17 2005, 08:58 AM
Post
#5
|
|
|
New Member ![]() Group: Members Posts: 6 Joined: 17-June 05 Member No.: 23,806 |
I have not compiled it but it will work I am certain.
#include <iostream> using namespace std; int main () { int first; int second; int third; float total; cin>>first; cin>>second; cin>>third; total=first+second+third/3; cout<<total<<endl; } |
|
|
|
Jun 17 2005, 04:30 PM
Post
#6
|
|
|
New Member ![]() Group: Members Posts: 6 Joined: 17-June 05 Member No.: 23,858 |
" total_scores=(firstscore + secondscore + thirdscore)/3";
that line of code will give you the average, however youhave not given a value to any of the scores. what you wanted to do was read in the first score which thagentalman showed you how to do in his code |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 22nd November 2008 - 03:27 PM |