Login Register


c++ shapes filter_list
Author
Message
c++ shapes #1
can someone explain to me how to use two nested while loops to create shapes? i just don't understand how they work really, i have a project due next week that involves making a trapezoid via user input and then after that it uses the same input to factor every number up to the user input number i can post

Reply

RE: c++ shapes #2
What do you mean by "shapes"? ASCII? graphical?
More information needed.

Reply

RE: c++ shapes #3
Code:
#include <iostream> using namespace std; int main() { unsigned size; bool solid = true;  //solid or hollow shape? cout <<"Size: ? "; cin >>size; size = 5; cout << endl; for ( unsigned r = 0; r < size; r++ ){ // Square    for ( unsigned c = 0; c < size ; c++ ){        if(solid){            cout << " * ";        }        else{            if(r == 0 || r == size-1 || c == 0 or c == size-1){                cout << " * ";            }            else{                cout << "   ";            }        }    }    cout <<endl; } cout <<endl; }
Like this the guy outputted a square with a user input

Reply







Users browsing this thread: