Hello,
I''m having problems with a program which involves functions.
The user is supposed to input the letter he wants printed out either I or F or Quit ,Q. He can start over with another letter after printing one out.
They can be between 5 and 11 stars in height but the width is always the same. Also the letter must be only an uneven number in height say 5, 7, 9, or 11.
The thing is the letters are always 5 in height and sometimes the letter F doesn't print out correctly if you start over after printing I.
I'm also supposed to use embedded for loops for the letters which is not what I've done.
Can anyone help me out?
PHP Code:
[CODE]
#include <stdio.h>
#include <ctype.h>
// shows user what choices he has
void showMenu() {
char I, F, Q;
printf("\n Menu\n");
printf(" I : Letter I\n");
printf(" F : Letter F\n");
printf(" Q : Quit\n");
printf(" Enter your choice:");
}
// reads choice of the user and validates it
char readChoice( )
{
char Choice;
Choice=toupper(getche());
}
// reads height of letters wanted and validates it
int readHeight(int min, int max )
{ int height;
printf("\n\nHeight of letter must be between 5 and 11\nEnter your height: ");
scanf(" %d", &height);
return 0; }
// drawI : draws the letter I
void drawI( int height) {
int i;
printf("*****\n");
for( i=0; i-2<=height;i++){
printf(" * \n");
}
printf("*****");
getch();
}
// drawF : draws the letter F
void drawF( int height) {
int i;
printf("*****\n");
printf("*\n");
printf("*****\n");
for (i=1; i-2<=height;i++)
printf("*\n", i);
scanf("%d", &i);
}
// systemPause
void Pause( )
{
printf("\n Press any key to continue");
getch();
} // end Pause
//main program
int main()
{
char Choice; // users' choice
int height; // height of the letter
do
{
showMenu();
Choice = readChoice();
if ( Choice != 'Q' )
{
height = readHeight( 5, 11);
switch (Choice)
{
case 'I' : drawI(height); break;
case 'F' : drawF(height); break;
}// end switch
} // end if
}// end while
while (Choice != 'Q');
Pause();
} // end main
[/CODE]