Rectangle Program in C Language with code
Name:-Rectangle
Description: -A simple program demonstrating tokenizing
Compiler: - Written for Dev-C++, but should work with any compiler
Notes:-The measurements are not correct (6x6 doesn't make a perfect square),
but they're as close as I could get using just text.
#include <iostream.h>
#include <stdlib.h>
int main()
{ int height, width, tmp, tmp2;
cout << "Please Enter The Height Of A Rectangle (whole numbers only): "; height: cin >> height;
if(height<1){cout << " Please Enter A Height Of Between 1 And 20: "; goto height;}
cout << "Please Enter The Width Of A Rectangle (whole numbers only): "; width: cin >> width;
if(width<1) {cout << " Please Enter A Width Of Between 1 And 38: "; goto width;}
cout << ' '; // Add a space at the start (to neaten top)
for(tmp=0; tmp!=width; tmp++) cout << "__"; // Top Of Rectangle
for(tmp=0; tmp!=(height-1); tmp++) {cout << "\n|"; // Left Side Of Rectangle
for(tmp2=0; tmp2!=width; tmp2++) cout << " "; // Create A Gap Between Sides
cout << "|";} // Right Side Of Rectangle
cout << "\n|"; // Left Side Of Bottom Of Rectangle to neaten bottom)
for(tmp=0; tmp!=width; tmp++) cout << "__"; // Bottom Of Rectangle
cout << '|'; // Right Side Of Bottom Of Rectangle (to neaten bottom)
cout << "\n\n"; system("PAUSE"); return 0;
}
Name:-Rectangle
Description: -A simple program demonstrating tokenizing
Compiler: - Written for Dev-C++, but should work with any compiler
Notes:-The measurements are not correct (6x6 doesn't make a perfect square),
but they're as close as I could get using just text.
#include <iostream.h>
#include <stdlib.h>
int main()
{ int height, width, tmp, tmp2;
cout << "Please Enter The Height Of A Rectangle (whole numbers only): "; height: cin >> height;
if(height<1){cout << " Please Enter A Height Of Between 1 And 20: "; goto height;}
cout << "Please Enter The Width Of A Rectangle (whole numbers only): "; width: cin >> width;
if(width<1) {cout << " Please Enter A Width Of Between 1 And 38: "; goto width;}
cout << ' '; // Add a space at the start (to neaten top)
for(tmp=0; tmp!=width; tmp++) cout << "__"; // Top Of Rectangle
for(tmp=0; tmp!=(height-1); tmp++) {cout << "\n|"; // Left Side Of Rectangle
for(tmp2=0; tmp2!=width; tmp2++) cout << " "; // Create A Gap Between Sides
cout << "|";} // Right Side Of Rectangle
cout << "\n|"; // Left Side Of Bottom Of Rectangle to neaten bottom)
for(tmp=0; tmp!=width; tmp++) cout << "__"; // Bottom Of Rectangle
cout << '|'; // Right Side Of Bottom Of Rectangle (to neaten bottom)
cout << "\n\n"; system("PAUSE"); return 0;
}