Storing data about food I'm trying to make a simple app to help me store data about food to use this database in a future diet application. What can I do to improve the code? What part of code should I make a class etc.?

    #include &lt;iostream&gt;
    #include &lt;vector&gt;
    #include &lt;string&gt;
    #include &lt;map&gt;
    #include &lt;iterator&gt;


    using namespace std;

    struct food
    {
        int mass;
        double kcal;
        double prot;
        double carb;
        double fat;
    };

    map&lt;string, food&gt; foodMap_prot;
    map&lt;string, food&gt; foodMap_carb;
    map&lt;string, food&gt; foodMap_fat;
    int main()
    {

        int mass;
        double kcal;
        double prot;
        double carb;
        double fat;
        string name;
        cout &lt;&lt; "Enter a name for a product: ";
        getline(cin,name,'\n');
        cout &lt;&lt; "\nmass of [" &lt;&lt; name &lt;&lt; "]: ";
        cin &gt;&gt; mass;
        cout &lt;&lt; "\ncalories of [" &lt;&lt; name &lt;&lt; "]: ";
        cin &gt;&gt; kcal;
        cout &lt;&lt; "\nprotein in [" &lt;&lt; name &lt;&lt; "]: ";
        cin &gt;&gt; prot;
        cout &lt;&lt; "\ncarbs in [" &lt;&lt; name &lt;&lt; "]: ";
        cin &gt;&gt; carb;
        cout &lt;&lt; "\nfat in [" &lt;&lt; name &lt;&lt; "]: ";
        cin &gt;&gt; fat;
        string kategory;
        double factor;
        kcal /= 100;
        prot /=100;
        carb /=100;
        fat /=100;
        food temp1 = {mass, mass*kcal, mass*prot, mass*carb, mass*fat};
        map&lt;string, food&gt;::iterator itr, koniec;
        if(prot&gt;carb &amp;&amp; prot&gt;fat)
        {
            factor = prot*100/7;
            mass = mass/factor;
            temp1 = {mass, mass*kcal, mass*prot, mass*carb, mass*fat};
            foodMap_prot[name] = temp1;
            itr = foodMap_prot.find(name);
            koniec = foodMap_prot.end();
            kategory = "Protein";
}
else if(carb&gt;prot&amp;&amp;carb&gt;fat)
{
    factor = carb*100/9;
    mass = mass/factor;
    temp1 = {mass, mass*kcal, mass*prot, mass*carb, mass*fat};
    foodMap_carb[name] = temp1;
    itr = foodMap_carb.find(name);
    koniec = foodMap_carb.end();
    kategory = "Carbs";
}
else if(fat&gt;prot&amp;&amp;fat&gt;carb)
{
    factor = fat*100/1.5;
    mass = mass/factor;
    temp1 = {mass, mass*kcal, mass*prot, mass*carb, mass*fat};
    foodMap_fat[name] = temp1;
    itr = foodMap_fat.find(name);
    koniec = foodMap_fat.end();
    kategory = "Fat";
}

for(;itr!=koniec; ++itr)
{
    cout &lt;&lt;"\n\nyou added a new product \t[" &lt;&lt; name &lt;&lt;"]";
    cout &lt;&lt;"\n\ncategory: \t\t\t" &lt;&lt; kategory;
    cout &lt;&lt;"\n\nmass of one block of [" &lt;&lt; name &lt;&lt; "]: \t" &lt;&lt; itr-&gt;second.mass&lt;&lt;"g";
    cout &lt;&lt;"\n\ncalories in [" &lt;&lt; name &lt;&lt; "]: \t" &lt;&lt; itr-&gt;second.kcal&lt;&lt;" kcal";
    cout &lt;&lt; "\n\nprotein [" &lt;&lt; name &lt;&lt; "]: \t"&lt;&lt; itr-&gt;second.prot&lt;&lt;"g";
    cout &lt;&lt;"\n\ncarbs [" &lt;&lt; name &lt;&lt; "]: \t" &lt;&lt; itr-&gt;second.carb&lt;&lt;"g";
    cout &lt;&lt; "\n\nfat [" &lt;&lt; name &lt;&lt; "]: \t" &lt;&lt; itr-&gt;second.fat&lt;&lt;"g";
}

    }
Namespace std
Stop doing this:
using namespace std;

See every other C++ code review and Why is “using namespace std;” considered bad practice?
Monolithic Functions
Break your code into multiple smaller functions. A good rule of thumb is no more than a dozen lines. If you give your function meaningful names then your code becomes self documenting.
Global Variables
Global variables are a bad idea. It makes testing hard. It makes debugging hard. You don't the result of the function biased on its inputs (it also depends on some other external global state that other functions may mutate while you are not watching.
Pass parameters to functions that should be the only state the worry about.
Objects
This looks like it should be an object:
map&lt;string, food&gt; foodMap_prot;
map&lt;string, food&gt; foodMap_carb;
map&lt;string, food&gt; foodMap_fat;

How about
class FoodMap
{
    typedef  std::map&lt;std::string, Food&gt;  FoodMap;

    FoodMap   protein;     // avoid the temptation to shorten names
    FoodMap   carbs;       // unless like this they are hard to spell.
    FoodMap   fat;
};

// Note on naming conventions.
// User defined types (usually) start with an Uppercase letters.
// Object usually start with a lowercase letter.
// This makes it easy to spot types over objects.

Looks like all the code in your main is designed to correctly fill up the map. So this should really be part of the FoodMap class. The class should be the only thing defining where things go internally. If you let functions (like main) fill up the map you have no control to validate input.