Welcome to BleepingComputer, 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.

# HELP ME !I HAVE A BUG IN MY PROGRAM!

5 replies to this topic

### #1 wds17

wds17

• Members
• 3 posts
• OFFLINE
•
• Local time:02:45 AM

Posted 17 April 2005 - 10:25 PM

. I also do not understand cc 1020

// 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]-%

### #2 wds17

wds17
• Topic Starter

• Members
• 3 posts
• OFFLINE
•
• Local time:02:45 AM

Posted 17 April 2005 - 10:56 PM

Any solutions can be sent to .

Mod edit: Email address removed for member's security. jgweed

Edited by jgweed, 17 April 2005 - 11:03 PM.

### #3 lucent

lucent

• Members
• 172 posts
• OFFLINE
•
• Gender:Male
• Local time:03:45 AM

Posted 16 May 2005 - 04:16 AM

i noticed no replies, are you still working on this?

Special thanks to efizzer for the signature

### #4 smilewithme

smilewithme

• Members
• 11 posts
• OFFLINE
•
• Local time:02:45 AM

Posted 19 May 2005 - 03:24 AM

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.

### #5 thagentleman

thagentleman

• Members
• 6 posts
• OFFLINE
•
• Local time:02:45 AM

Posted 17 June 2005 - 08:58 AM

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;
}

### #6 cowwy

cowwy

• Members
• 6 posts
• OFFLINE
•
• Local time:02:45 AM

Posted 17 June 2005 - 04:30 PM

" 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

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users