Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,397 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,108 people online right now. Registration is fast and FREE... Join Now!




In Extreme need of troubleshooting help ASAP

 
Reply to this topicStart new topic

In Extreme need of troubleshooting help ASAP

navalurzu7
20 Sep, 2006 - 05:55 PM
Post #1

New D.I.C Head
*

Joined: 20 Sep, 2006
Posts: 1


My Contributions
I really need help debugging a LOT of programs i've been having trouble coding all day today...its my homework for my C++ class, i have to program 16 programs....and i've only been able to do a few, and 4 of them dont work right, and i cant figure out WHY! I need help asap because its due tomorrow night T_T

here's the first code, its for a simple program that tells you the smallest grade out of however many you put into it. It is also supposed to tell you in the end how many grades were entered as well as the total of all the grades combined. My problem is that i cant get it to add up the grades right... and its driving me crazy!

#include <iostream.h>

#include <iomanip.h>


int main ()

{

int grade, number, smallest;

float total;

total = 0;

cout << "Enter the number of grades ";

cin >> number;

cout << "Enter grade #1 ";

cin >> smallest;

for(int count = 2; count<=number; count++)

{

cout << " Enter the grade # "<<count<<" ";

cin >> grade;

if(grade<smallest)

smallest = grade;

}

grade = smallest;

total = grade + smallest;

cout << " The total of all the grades is "<<total<<endl;

cout << " Number of grades entered was "<<number<<endl;

cout << " Smallest grade is "<<smallest<<endl;

return 0;

}
User is offlineProfile CardPM
+Quote Post

Xing
RE: In Extreme Need Of Troubleshooting Help ASAP
20 Sep, 2006 - 06:04 PM
Post #2

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
This is not the right approach to do it but anyways see the changes
CODE

int main (){
    int grade, number, smallest;
    float total;
    total = 0;
    cout << "Enter the number of grades ";
    cin >> number;
    cout << "Enter grade #1 ";
    cin >> smallest;
    total=total+smallest;
    for(int count = 2; count<=number; count++){
    cout << " Enter the grade # "<<count<<" ";
    cin >> grade;
    total=total+grade;
    if(grade<smallest)
    smallest = grade;
    }
    cout << " The total of all the grades is "<<total<<endl;
    cout << " Number of grades entered was "<<number<<endl;
    cout << " Smallest grade is "<<smallest<<endl;
return 0;
}


PS : Read the rules of the forum before posting any other question again.

This post has been edited by Xing: 20 Sep, 2006 - 06:06 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:59AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month