7 Replies - 1149 Views - Last Post: 17 May 2001 - 05:24 PM Rate Topic: -----

#1 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,409
  • Joined: 21-March 01

for loops

Posted 15 May 2001 - 07:09 PM

i got some code:
for(j=0;j<7;j++)
{for(n=0;n<7;n++) 
{
cout << setprecision(4) << "Day #"<<j+1<<":"<<temp[i][n]<<setw(16)<<(((temp[i][n]-32.0)/9.0)*5.0)<<setw(25)<<(((temp[i][n]*9.0)/5.0)+32.0)<<'
';
}
}

i want this to go thru so that the variable j goes up at the same time that variable n goes up. thanx in advance.

(Edited by supersloth at 9:18 pm on May 15, 2001)


Is This A Good Question/Topic? 0
  • +

Replies To: for loops

#2 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,409
  • Joined: 21-March 01

Re: for loops

Posted 15 May 2001 - 07:52 PM

i kinda got it. it looks like this:

for(n=j=0;n<7;n++&&j++)


but the problem is that it has an out put of this:

         Day #         Celsius Reading        Farenheit Reading
         -----         ---------------        -----------------

       Day #1:87           30.56                    188.6
       Day #1:69           20.56                    156.2
       Day #2:32               0                     89.6
       Day #3:0          -17.78                       32
       Day #4:89           31.67                    192.2
       Day #5:444           228.9                    831.2
       Day #6:-21          -29.44                     -5.8
The average Celsius reading for this 7 day period is: 37.78
The average Farenheit reading for this 7 day period is: 212

this is dumb becuase if you look it is saying day#1 twice. it should say day#1-7. thanx in advance.

Was This Post Helpful? 0
  • +
  • -

#3 nighthawk  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 1,269
  • Joined: 11-April 01

Re: for loops

Posted 15 May 2001 - 08:27 PM

ok sloth, a couple of questions, what's the number next to the day?  if that's the input temperature, i strongly suggest that you ask the user what units they are inputing, it's important and your way is not effecient, not to mention that it doesn't look neat.  Please listen to me, i'm only trying to help you.  Next, i need to see the code that generated the output that you showed that way i can figure out where you went wrong.  I think that that's everything, i desparatly hope that you will listen to me, this isn't something that my C++ teacher in highschool would accept.
~Nighthawk
Was This Post Helpful? 0
  • +
  • -

#4 kalpeshmjoshi  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 25-April 01

Re: for loops

Posted 15 May 2001 - 08:28 PM

for(j=0;j<7;j++)
cout << setprecision(4) << "Day #"<<j+1<<":"<<temp[j]<<setw(16)<<(((temp[j]-32.0)/9.0)*5.0)<<setw(25)<<(((temp[j]*9.0)/5.0)+32.0)<<'
';
Test it, Is it works ?
[color=blue]
Was This Post Helpful? 0
  • +
  • -

#5 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,409
  • Joined: 21-March 01

Re: for loops

Posted 16 May 2001 - 08:27 PM

first off, even i dont know what the problem is about. if i knew, i would put it in, but i dont. secondly, no the code didnt work. any other ideas?
Was This Post Helpful? 0
  • +
  • -

#6 kalpeshmjoshi  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 25-April 01

Re: for loops

Posted 17 May 2001 - 01:52 AM

Post the Result of the Screen
[color=Blue]

(Edited by kalpeshmjoshi at 3:01 am on May 18, 2001)

Was This Post Helpful? 0
  • +
  • -

#7 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,409
  • Joined: 21-March 01

Re: for loops

Posted 17 May 2001 - 04:48 PM

never mind i got it.
Was This Post Helpful? 0
  • +
  • -

#8 nighthawk  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 1,269
  • Joined: 11-April 01

Re: for loops

Posted 17 May 2001 - 05:24 PM

good to know that you figured it out :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1