Write a C++ program using DarkGDK with functions that asks the user for a positive integer no greater than 15. The program should then display a square on the screen using the character “X”. The number entered by the user will be the length of each side of the square. For example, if the user enters 5 the program should display the following:
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
If the user enters 8, the program should display the following: XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX

Thanks for posting your homework question. Now what is -your- question?

And sorry, I have no working knowledge of your DarkGDK, but there is a set of related threads pointed out on the right-hand-side of the screen here, they may be helpful to you as well.

hi darkGDK 2D is one of c++ codes this is how it look it is in c++
#include "DarkGDK.h"
what I need is the beginning of the while loop I'm suppose to use in writing this program
thank u

Sorry to be so abrupt before, and welcome to DaniWeb. When you get a chance, please read the "Read this before posting" sticky-post at the top of the forum list, it provides lots of helpful advice (including "don't post your homework assignment and wait for somebody to solve it for you", wink, wink).

So a while loop looks like:

while (someExpressionIsTrue) {
    // do something that needs to be done
}
// program execution will resume here when the expression is no longer true

Personally, for nice fixed-size loops, I'd use for() loops instead of while() loops, but either will work. Either way, you need to determine (a) what expression you wish to evaluate, and (b) what needs to be done within the loop. Consider also, that since the number of lines to be printed, and the length of each line, are both dependent on the input, you may wish to have two nested loops in the form:

while (expression1) {
    // maybe do something here
    while (expression2) {
        // do something here
    }
    // maybe do something here
}

Keep in mind that part of what needs to be done in a loop may include adjusting a value that is examined as part of the expression in the while() statement.

Does this help?

This article has been dead for over six months. Start a new discussion instead.