Help with this code?
Feb 27, 2016 at 11:57pm UTC
Hi i created this code and I want to finish it , it says there are no errors but Nothing is working no shapes are being drawn up when i compile
Can someone help me out and tell me what im missing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
#include <iostream>
using std::cout; using std::endl; using std::cin;
void filledSquare(int );
void rightTriangle(int );
void leftTriangle(int );
void hollowSquare(int );
int main(){
int num, shape, inside;
cout << " 1. Square" << endl;
cout << " 2. bottom left triangle" << endl;
cout << " 3. top right triangle" << endl;
cout << "select figure" << endl;
cin >> shape;
cout << " select size" << endl;
cin >> num;
while (shape == 1){
char inside;
cout << " filled or hollow [f/h]:" <<endl;
cin >> inside;
if (inside == 'f' )
void filledSquare();
else if (inside == 'h' )
void hollowSquare();
}
if (shape == 2)
void leftTriangle();
if (shape == 3)
void rightTriangle();
}
void filledSquare(int num){
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
cout << "*" ;
cout << endl;
}
}
void hollowSquare(int num){
for (int i = 0; i <= num; i++)
{
for (int j = 0; j <= num; j++)
if (i == 0)
cout << "*" ;
else if (j == 0)
cout << "*" ;
else if (j == num)
cout << "*" ;
else if (i == num)
cout << "*" ;
else
cout << " " ;
cout << endl;
}
}
void rightTriangle(int num ){
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
if (i > j)
cout << " " ;
else
cout << "*" ;
cout << endl;
}
}
void leftTriangle(int num){
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
if (i >= j)
cout << "*" ;
cout << endl;
}
cout << endl;
}
Last edited on Feb 28, 2016 at 12:00am UTC
Feb 28, 2016 at 12:09am UTC
void filledSquare();
is the declaration of a function named filledSquare which takes no parameters and returns nothing. It is not a function call.
Feb 28, 2016 at 12:15am UTC
im soo stupid.. thankks i finished it haha
Topic archived. No new replies allowed.