Jump to content

Some Questions about C# codes

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Beginner Sarah

Beginner Sarah

    Newbie

  • Members
  • Pip
  • 1 posts
Hello all ,
i am a beginner in programming and i need your help please,

i want to find the maximum , minimum , average , standard divtion and Mod for an array ,
and i am really stuk !

i used this Code for finding the maximim and it doesn't work !

int i;

            double max = x[0];

            for (i = 1; i < x.Length; i++)

                if (x[i] > max)

                    max = x[i];

            textBox10.Text = max.ToString();

and this one for manimum and also doesn't work

int i;

            double min= x[0];

            for (i = 1; i > x.Length; i++)

                if (x[i] < min)

                    min= x[i];

            textBox9.Text = min.ToString();

Help me please :crying:

#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US

Beginner Sarah said:

int i;

            double max = x[0];

            for (i = 1; i < x.Length; i++)

                if (x[i] > max)

                    max = x[i];

            textBox10.Text = max.ToString();

Which part exactly doesn't work? Is there an error on a specific line? I don't know if there's anything wrong with the syntax (I don't know C#), but the algorithm seems like it should work.

Also the minimum algorithm, too, seems to me like it should work.

Is it a compiler error, or if it compiles well, what's the behavior of the program?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users