For my intro to c++ class I have to create a complete program from broken algorithms
The questions are
(a) Print a random number between -1 and -9 to the output screen:
(b) Print (to the output screen) the sum of the square roots of the numbers 1, 2, 3 , 4, 5 and 6.
c) Ask the user to enter the word ”Hello”. Force the user to keep entering a new word until an input equal to ”Hello” is received.
(d) Print twelve random negative numbers.
(e) Print the largest integer whose square root is less than 1729.
So far I have
a)int r = rand() % 9 + 1;
cout << -r;
b)double sum = 0;
for (int s = 1; s <= 6; s++)
sum += sqrt(s);
cout << sum;
c)string input = "";
while (input != "Hello") {
cout << "Please enter the word ’Hello’: ";
cin >> input;
}
d)for (int n = 1; n <= 12; n++) {
int r = rand();
if (r > 0) r = -r;
cout << r;
}
e)int n = 1;
while (sqrt(n) < 1729) n++;
cout << n - 1;
How can I make a program that incorporates all these algorithms and that flows well. Thanks