PLEASE check my coding...

May 18, 2012 at 09:34:45
Specs: Windows XP
#include<stdio.h>
#include<conio.h>

main()
{
char name [30];
char id;
int height;
float weight;
float bmi;
// input

printf("\n Enter your name:");
scanf("%s",&name);

printf("\n Enter your Matric Number:");
scanf("%s",&id);

printf("\n Enter your weight(kg):");
scanf("%.2f",&weight);

printf("\n Enter your height(m):");
scanf("%d",height);

//process

bmi = (weight / (height * height));

// output

printf("\n\n Name: %s", name);
printf("\n\n Matric Number: %s", &id);
printf("\n\n Your BMI: %.2f", &bmi);

getch();
}


See More: PLEASE check my coding...

Report •

#1
May 18, 2012 at 14:50:32
I am not near a C++ compiler, but I think you have a problem here:

printf("\n\n Matric Number: %s", &id);
printf("\n\n Your BMI: %.2f", &bmi);

There is no need for the address:

printf("\n\n Matric Number: %s", id);
printf("\n\n Your BMI: %.2f", bmi);


Report •
Related Solutions


Ask Question