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.");
}
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.