samedi 28 février 2015

Beginner C Programmer in Need of Assistance with Creating a Letter Pyramid

I'm just learning how to start programming with C, and I'm stumped on this question. My code compiles, and it works initially, but it won't print after the initial prompt of asking the user to input a letter. Here is what my code currently looks like



intmain(void
{
char letter = 'A';
char display;
char output;
int row;
char spaces = ' ';

printf ("Please enter a lowercase letter!");
scanf ("%c", &letter);

while ((letter < 96) || (letter > 122))
{
printf ("That's not lowercase.");
scanf ("%c", &letter);
}

else if ((letter > 96) || (letter < 122))
{
while (1)
{
letter = letter - 32;
printf ("%c", letter -1);
printf("\n\n");
spaces = letter - 1;
putchar = (spaces);
letter++
spaces++
}
}

return 0;
}
}


The end result should be this for example. Say that the user entered E:


----------A


---------ABA


--------ABCBA


-------ABCDCBA


------ABCDEDCBA


So, the letter entered would be the center letter on the bottom of the pyramid.


Aucun commentaire:

Enregistrer un commentaire