Quote (irimi @ Sep 20 2012 05:14pm)
your while loop condition is backwards. right now, the program will keep restarting as long as the user types "n" or "N" for the last part.
yea i fixed that now.
having trouble making it prompt me for typing a single char instead it just skips to the restart program part
using Hercules to display it btw
Code
int main(void)
{
char Quit = 'y';
do
{
// Declare four variables and choose their appropriate type, such as int, or float. Use a meaningful name based on the following uses:
// A variable to store the age (in years) of the user
int age_years;
// A variable to store the age in months.
int age_months;
// A variable to store the height in inches of the user.
int height_inches;
// A variable to store the height in centimeters.
float height_centimeters;
char test_one;
// Ask the user to input their age in years and store it to your age variable.
printf ("\nWhat is your age in years? \n");
scanf ("%i", &age_years);
// Ask the user to input their height and store it to your height variable in inches.
printf ("What is your height in inches? \n");
scanf ("%i", &height_inches);
// Calculate the age in months and store it to the appropriate variable.
age_months = age_years * 12;
// Calculate the height in centimeters (2.54 cm per inch) and store it to the appropriate variable.
height_centimeters = height_inches * 2.54;
// Output the user's age in months and years, height in inches, and height in centimeters.
// The height in centimeters should only display 2 decimal digits.
printf ("You are %i years old \nYou are %i months old \nYour height is %i inches \nYour height is %0.2f centimeters\n \n", age_years, age_months, height_inches, height_centimeters);
printf ("Type a single char \n");
getchar();
scanf ("%c", &test_one);
printf ("You printed this char %c \n", test_one);
// Misc for fun.. restart program
printf ("Restart Program? (y/n) \n");
scanf ("%c", &Quit);
}
while (Quit == 'y' || Quit == 'Y');
}