Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why isn't the program taking decimals?

+1 vote
asked May 5, 2021 by jaime parker (140 points)
I am in learning of c++ and i had absolutely no problem with decimals until now, ill show the code.

 #include <iostream>
using namespace std;
int p,e,i;
int main()
{
    cin >> p;
    cin >> e;
    i=p/(e+e);
    cout << i;
    if (i>24);
    else
    cout << " Normal";
    if (i<25);
    else
    cout << " Overweight";
}

p= weight of the person         e= height of the person        i= body mass index

What could i do to see decimals again :(

1 Answer

0 votes
answered May 15, 2021 by xDELLx (10,500 points)
Use the float, double data type, It should handle the decimal types..

Also using auto variables would help.

declareas below.

auto p=0.0;

auto q = 0.0
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...