Hi
I was wondering if I could get a little help with some programs I'm currently making.
The first is a program designed to calculate BMI by inputting in stones and pounds and converting to kg and metres.
This is what i have so far but unsure as to why it isn't working.....
Code:
#include <stdio.h>
int main() {
int Feet;
int Inches;
int Stones;
int Pounds;
double Kilo = 0;
double Meter = 0;
char BMI = 0;
printf("Please enter your height in UK Feet and Inches: ");
scanf("%d %d", &Feet, &Inches);
printf("Please enter your weight in Stones and Pounds: ");
scanf("%d %d", &Stones, &Pounds);
Kilo =((Stones *14)*0.4536)+(Pounds*0.4536);
Meter = ((Feet * 0.3048) + (Inches * 25.4));
BMI = (Kilo / ( Meter * Meter) );
printf("%c", BMI);
return 0;
}
My other program is designed to calculate an area of a shape.(prompting user input first) This program doesn't compile and won't run in Cygwin....any suggestions on the error in my code?
Code:
#include <stdio.h>
int main(){
float Rlength, Rwidth, Slength, Swidth, Cradius, AOR, AOC, AOS;
char Sha;
char R, S, C;
printf ("\nArea of Shapes Calculator");
printf ("\nPlease enter for calculation, S=Square, R=Rectangle, C=Circle");
scanf ("%c", &Sha);
if (Sha == 'R')
printf ("\nEnter the Length and width of the Rectangle:");
scanf("%f,%f", &Rlength, &Rwidth);
AOR = Rlength * Rwidth;
printf("%f\n", AOR);
endif;
if (Sha =='S')
printf ("\nEnter the length and width of the Square:");
scanf ("%f,%f", &Slength, &Swidth);
AOS = Slength * Swidth;
printf("%f\n", AOS);
endif;
if(Sha == 'C')
printf("\nEnter the Radius of the Circle:");
scanf("%f", &Cradius);
AOC = 3.141 * Cradius * Cradius;
printf("%f\n", AOC);
endif;
return 0;
}
I would appreciate any help as i'm fairly new to C!
Thanks