Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
Stuck on an exercise question
Post Flair (click to view more posts with a particular flair)
Post Body

I am in Chapter two of C Without Fear, working on exercise 2.2.2, the "count" examples. The example has you enter a number and the program counts from 1 to the number entered, and the exercise is to change the code and count down from the number entered. The example is:

#include <iostream>

using namespace std;

int main()

{

int i = 1, n = 0;

cout << "Enter a number and press ENTER: ";

cin >> n;

while (i <= n) {

    cout << i << " ";

    i = i   1;

}

return 0;

}

I need to change things around to where it counts down from number entered to 1. I cant seem to figure out what seems should be so easy to figure out.

Author
Account Strength
100%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
7,045
Link Karma
3,781
Comment Karma
2,751
Profile updated: 2 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago