guys i just ask some questions about making a dev c++ codes in ascending numbers order. executing the first number then the next number increasing the number adds to it. its like a loop. tnx guys for d help. any help. pls. im needing dis for my defend. im starting to make a program but always fail. :<

Recommended Answers

All 10 Replies

Is it a sort you are looking for? Please try to be as clear as possible tnx guys for d help. any help. pls. im needing dis for my defend. sounds like your texting your friends instead of asking colleagues for help.

please show what you have done first

Heres my code:

#include<iostream>
using namespace std;
int main()
{
    int x;
    x=3;
    while(x<=47)
    {
                cout<<x<<endl;
                x++;
                }
                system("pause");
                return 0;
               }

out put of it is starting to 3 to 47, but the program should be start to 3 adding 2 to output 5 then add 3 to output 8 adding number is increasing til it get to 47. sorry guys! any help?

5 is an odd number, 8 is an even number, how can you determine if a number is odd or even? Look into the modulus operator(%).

its the increment i mean here i want the increment to add increase. what do i use to make it possible excepting the while loop.

Take a few minutes and think about it a little bit- how could you conditionally increment a variable?

any other option or condition could do this? thanks jonsca

if(number is even)
   do this
else
   do this

I've given you way too much already.

thank you by the way. i'll just solve it with your help and others help. thanks.

You're welcome. I'm willing to work with you, but I'm not going to give you the answer. This is like assignment #1 of a course, so you need to be able to take what you learned so far and apply it, otherwise it's going to be a long painful road for the remainder. I'm not trying to be harsh, just trying to help you learn how to learn the material.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.