while or for loops

The output should look like this:

100 102 104 106 108 110
112 114 116 118 120 122
124 126 128 130 132 134
136 138 140 142 144 146
148 150

-2.3 -1.9 -1.5 -1.1 -0.7 -0.3 0.1 0.5 0.9 1.3 1.7 2.1 2.5 2.9
Sum of negative values: -7.8
Sum of positive values: 12

This is my code so far:

#include <iostream>

int main () {
int rows, cols, sum;
double count;

cout << "CSE 1020 Lab 7 Pgm 1 Justin Prater " <<
"justinprater@my.unt.edu" << endl << endl;


for (count = 100; count <= 150; count += 2)
cout << count << " ";

cout << endl << endl;

for (count=-2.3; count <= 2.9; count += 0.4)
cout << count << " ";



return 0;
}

IDK how to make the first part only output on six lines.

And IDK what the formula is to calculate the negatives and positives of the 2nd one
uh u dont know the formula to calculate the sum of neg and pos? lol
add up all the neg for sum of neg val and add all the pos for sum of pos val....
and for the loop, add another loop that go from how many rows you want in the output. so u want 6 than loop from 1 to 6
ive been told plenty of times... haha i cant put it into code
here <<for (count = 100; count <= 150; count += 2)
cout << count << " ";>> when you print a number you should caculate how many numbers you've had print, then you will see if it became 6 than you will print a new line, like this:
#include <iostream>

int main () {
int rows, cols, sum,counter=0;
double count;

cout << "CSE 1020 Lab 7 Pgm 1 Justin Prater " <<
"justinprater@my.unt.edu" << endl << endl;


for (count = 100; count <= 150; count += 2)
{
cout << count << " ";
counter++;
if(counter==6)
{
cout << endl;
}
}

cout << endl << endl;

for (count=-2.3; count <= 2.9; count += 0.4)
cout << count << " ";



return 0;
}
Topic archived. No new replies allowed.