Heey,
I just started programming and im trying to create programs as im learning.
I was creating this program which would make sideway pyramids where you could choose the symbol and width of the pyramid.
When i tried to make the program more complex, i couldn't enter a 2digit width anymore.
If i enter a 2digit number in directy goes to:
I tried my best to fix it but i can't.Code:cout << "\n\nPress [N] to try again." << endl; cout << "Press [Q] to quit." << endl;
Here's a complete copy of my code:
Hope someone could help me out, thanks in advance.Code:#include <iostream> using namespace std; int a = 1; int b = 0; int d = 0; int x = 0; int width; char option; char c; int main() { if(d == 0) { system("CLS"); cout << ":: Welcome to Sideway Piramid program ::" << endl; cout << "\tChoose a letter to build te pyramid with (AaBbYyZz): "; cin >> c; if(c != c){return main();} cout << "\n\tEnter a width (1 - 30 Characters)?: "; cin >> width; cin.get(); if(width > 30 || width < 1){return main();} d = 1; } if(a == 0) { cout << "\n\nPress [N] to try again." << endl; cout << "Press [Q] to quit." << endl; cin >> option; if(option == 'Q' || option == 'q'){return 0;} else if(option == 'N' || option == 'n') { d = 0; return main(); } else { cout << "\n\nInvalid Key, Press [Enter] to exit."; cin.get(); cin.get(); cout << "\n\nExiting..."; return 0; } } if(a == width){b = 1;} if(b == 0) { for(x = 0; x < a; x++){cout << c;} a++; cout << endl; return main(); } if(b == 1) { if(a == 0){d = 0;} for(x = 0; x < a; x++){cout << c;} a = a - 1; cout << endl; return main(); } }
Onii



LinkBack URL
About LinkBacks





Anyhow, thanks a lot, i'll figure it out from this point on 
CornedBee