0

hello guys,
i found a piece of code in the net..
this code is a progress bar loop programme.
I am new to programming, and i am not able to understand this code.
PLEASE can anyone explain it or tell a simpler version of it.
thanks(sorry for my english)

#include <iostream>

#define N1 1000000000
#define N2  100000000

using namespace std;

int main (void)
{
    int counter;

    for (counter = 0; counter < (N1+1); ++counter) {
        if ((counter / N2) == 2 && (counter % N2) == 0) {
            cout << "[====                ]20%\r";
        }
        else if ((counter / N2) == 4 && (counter % N2) == 0) {
            cout << "[========            ]40%\r";
        }
        else if ((counter / N2) == 6 && (counter % N2) == 0) {
            cout << "[============        ]60%\r";
        }
        else if ((counter / N2) == 8 && (counter % N2) == 0) {
            cout << "[================    ]80%\r";
        }
        else if ((counter / N2) == 10 && (counter % N2) == 0) {
            cout << "[====================]100%" << endl;
        }
    }

    return 0;
}
2
Contributors
2
Replies
14
Views
3 Years
Discussion Span
Last Post by Vikram Sehgal
0

get your compiler and change some variable, like the value of N1/N2,
make N1+0 or just anything, after a while. u can learn the algorithm by yourself.

-1

the thing is i did not understand the code, as i said i am new...
CAN SOME ONE EXPLAIN IT TO ME?? thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.