Write your question here.
Hello everyone, I am new in programming. This is one of my exercise and I don't know why I can't put more than one character inside variable (name) and BMI also cannot be calculated. Sry for the bad language...
#include <iostream>
using namespace std;
int main()
{
int BMI, weight, height;
char name;
cout << "Please enter your name: " << endl;
cin >> name;
cout << "Plaese enter your weight: " << endl;
cin >> weight;
cout << "Please enter your height" << endl;
cin >> height;
cout << "_____________________________________________" << endl;
BMI= weight/(height*height);
cout << "Name :" << name << "\nWeight" << "\tHeight" << "\tBMI" << endl;
cout << weight << "\t" << height << "\t" << BMI << endl;
What Moschops says.
"char" represents a character - 8 bits of memory. The computer will read only one character. If you type "John", it will read "J" into name and "o" into weight".