mardi 28 avril 2015

How to increase a counter inside of a do-while loop with if-else condition (c++)

Hey guys I'm trying to build a program that calculates a percent composition of a compound.

There is an array of elements such as H, O, C end etc

The program must take the user_compound and compare it to the array of elements and return the value(mass) that is in the same position.

Unfortunately right now it works just for H and than it loops any ideas on how to increase the i( i.e run i++ part) ?

do{

        cin >> user_compound[i];

            if(user_compound[i][i] == elements[i][i]){

               cout << "this is user compound " << user_compound[i][i] << << " "<< values[i]<<endl;}

            **else{
                i++;}}**

    while(user_compound[i][i] == elements[i][i]);

Aucun commentaire:

Enregistrer un commentaire