naruto9's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
New Members
Active Posts:
13 (0.07 per day)
Joined:
06-November 12
Profile Views:
83
Last Active:
User is offline Dec 12 2012 10:42 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   naruto9 has not set their status

Posts I've Made

  1. In Topic: [C++] arrays - filling entries with odd numbers

    Posted 25 Nov 2012

    Ok, Just answered my own question. just have to declare int z and put z=z+2 after the 'cout<<odd[y][x];'
  2. In Topic: Simple fahrenheit to celcius conversion using arrays

    Posted 14 Nov 2012

    wow, i see. That makes complete sense, Thank you.
  3. In Topic: finding a max value in values entered for average, using arrays.

    Posted 13 Nov 2012

    View PostSkydiver, on 13 November 2012 - 02:15 PM, said:

    The problem is due to line 10 of your code. You are letting max take the uninitialized value of score[0]. You probably want to do that after score[0] has been initialized with some input.



    Thank you! This helped get my max and min values as well.
  4. In Topic: finding a max value in values entered for average, using arrays.

    Posted 13 Nov 2012

    View Postjimblumberg, on 13 November 2012 - 02:11 PM, said:

    Topics merged, please don't open duplicate topics for the same problem.

    Jim



    View PostSkydiver, on 13 November 2012 - 02:15 PM, said:

    The problem is due to line 10 of your code. You are letting max take the uninitialized value of score[0]. You probably want to do that after score[0] has been initialized with some input.


    Im really sorry about this duplication, I was not aware of this at all or how this happened, but after previewing my post, I simply clicked post. I'll try that skydiver, thanks.
  5. In Topic: finding a max value in values entered for average, using arrays.

    Posted 13 Nov 2012

    Hi,
    In this program we are to use arrays and this is an intro to arrays for us(one dimensional).
    The error is that when i run the program its not giving me the max value but a large random number.
    How can i get a max value from the values I enter?

    here's the task:

    b. Write a program that allows the user to enter 10 test grades. You should store these grades in an array called SCORE. Find the average test grade as well as the maximum and minimum test grades. Output the 10 test grades, the average test grade, the maximum test grade, and the minimum test grade. Be sure to label all your output.

    the teacher gave us the code to use for max, but i can't figure it out:
    For(I=1; I<=9; I=I+1)
    { if (Max<ary[I])  //tests to see if each of the values is bigger than what’s in Max.
       {Max=ary[I];   //if the value is bigger, it stores that value in Max.
       }
    }
    //at this point in the code, the biggest value in ary is stored in Max.
    
    


    and my attempt:

    #include <iostream>
    #include <math.h>
    
             using namespace std;
             int main() {
                 int score[10],x;
                 float sum=0;
                 float average;
                 float max;  //assumes that the first value in the array is the biggest - gets us started
                 max=score[0];
                 for(x=0;x<=9;x=x+1)
                 {
                      cout<<"Enter the test score: ";
                      cin>>score[x];
                               
                 }
                 for(x=0;x<=9;x++)
                 {
                     sum+=score[x];
                 }
                 for (x=0; x<=9; x=x+1)
    
                 {    
                      cout<<score[x]<<"\n";
                      
                 }
                 for(x=1; x<=9; x=x+1)
                 { if (max<score[x])  //tests to see if each of the values is bigger than what's in Max.
                 {max=score[x];   //if the value is bigger, it stores that value in Max.
                 }
                 }
                 //at this point in the code, the biggest value in ary is stored in Max.
                 cout<<"max: "<<max<<endl;
                 cout<<"sum: "<<sum<<endl;
                 average=sum/10;
                 cout<<"average: "<<average<<endl;
                 system("pause");
                 return 0;
                 }
                 
    
    


    Thank You

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

naruto9 hasn't added any friends yet.

Comments

naruto9 has no profile comments yet. Why not say hello?