Don't know whats keeping this from working

Hello, I am trying to write a basic program that asks a person their name and their height in inches, then displays their height in cm. When I run this program, it asks my name, and when I input that the program stops completely. I have looked over it and do not know what is wrong with it, some help would be much appreciated

#include <stdio.h>
int main ()
{

int inches=0;
char name=name;
float cm=0;

printf("Please enter your name:");
scanf("%c" , &name);

printf ("Please enter your height in inches:");
scanf("%d", &inches);

if (inches>=0);
{
cm = inches*2.54;
printf("Hello %c, you are %f cm tall. \n", name, cm);
}

if (inches<0);
{
printf("You cannot be negative inches tall, try again.");
}

return 0;
}
char name=name is not a good way to initialize a variable. You should give it a value.

Your if statements should not have semicolons after the conditions.

What are you typing in exactly?
char name=name;

Don't you get compile errors(or even warnings) for this?
Moreover, a char is 1B(Byte) in size, and only holds one or two characters. So making it a char* should help.

EDIT: Also omit the semi-colons after the if statements.

HTH,
Aceix.
Last edited on
Topic archived. No new replies allowed.