Welcome to Dream.In.Code
Become a C++ Expert!

Join 150,217 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,130 people online right now. Registration is fast and FREE... Join Now!




NEED HELP

 
Reply to this topicStart new topic

NEED HELP

grimmben
2 Dec, 2007 - 12:04 AM
Post #1

New D.I.C Head
*

Joined: 25 Nov, 2007
Posts: 27


My Contributions
CODE
displays the numbers 10 through 1
//Created/revised by <your name> on <current date>

#include <iostream>

using std::cout;
using std::endl;

int main()
{
    
    for (int count = 10; count <= 8; count = count + 1)
        (count + 1);
        cout << count << endl;

    //display numbers
    
    
    return 0;
}   //end of main function


User is offlineProfile CardPM
+Quote Post

Martyr2
RE: NEED HELP
2 Dec, 2007 - 12:13 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Changes made:

1) Changed for loop to start at 10 and continue as long as it is GREATER THAN 1. Also made it decrement by 1, not add.

2) Added curly braces for better readability.

3) Removed (count+1) not sure why it was there, but it is not a valid statement by itself and if you are moving from 10 to 1, you need to be subtracting, not adding to.

CODE

displays the numbers 10 through 1
//Created/revised by <your name> on <current date>

#include <iostream>

using std::cout;
using std::endl;

int main()
{
    
    for (int count = 10; count >= 1; count = count - 1) {
        cout << count << endl;
    }

    //display numbers
    
    
    return 0;
}   //end of main function


Hope that is what you were attempting to do, count down from 10 to 1 one at a time.

Enjoy!

"At DIC we be reverse counting code ninjas!" decap.gif
User is offlineProfile CardPM
+Quote Post

grimmben
RE: NEED HELP
2 Dec, 2007 - 12:20 AM
Post #3

New D.I.C Head
*

Joined: 25 Nov, 2007
Posts: 27


My Contributions

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

QUOTE(Martyr2 @ 2 Dec, 2007 - 01:13 AM) *




Changes made:

1) Changed for loop to start at 10 and continue as long as it is GREATER THAN 1. Also made it decrement by 1, not add.

2) Added curly braces for better readability.

3) Removed (count+1) not sure why it was there, but it is not a valid statement by itself and if you are moving from 10 to 1, you need to be subtracting, not adding to.

CODE

displays the numbers 10 through 1
//Created/revised by <your name> on <current date>

#include <iostream>

using std::cout;
using std::endl;

int main()
{
    
    for (int count = 10; count >= 1; count = count - 1) {
        cout << count << endl;
    }

    //display numbers
    
    
    return 0;
}   //end of main function


Hope that is what you were attempting to do, count down from 10 to 1 one at a time.

Enjoy!

"At DIC we be reverse counting code ninjas!" decap.gif

biggrin.gif biggrin.gif

This post has been edited by grimmben: 2 Dec, 2007 - 12:22 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/9/09 05:30AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month