Simple dishwasher C++ code I have a project in embedded systems and I have to write the code in C, and make it simple.

This is my first time, and it's only a simulation of how it should work.

#include&lt;iostream.h&gt;
#include&lt;stdio.h&gt;

void manualMode();
 void defaultMode();

int temp, timeToWash, operation;

int main() {
     int mode =0, part=3, waterLevel;
     int doorSensor=0, timer = 3,waterLevelSensor = 0, tempSensor = 25;
     char startPause;
     cout&lt;&lt;"Washing Machine CE224"&lt;&lt;endl;
 do{
      cout&lt;&lt;"Choose Mode: (1)Default, (2)Manual \n";
      cin&gt;&gt;mode;
      if (mode == 1)
                 defaultMode();
      if (mode == 2)
                 manualMode();
 }while(mode == 0);

 cout&lt;&lt;"Choose Parts to wash: (1)Upper Only, (2)Lower Only, (3)Upper and Lower \n";
 cin&gt;&gt;part;
 switch(part){
            case 1:
            case 2:
                 waterLevel= 0.5;
                 break;
            case 3:
                 waterLevel = 1;
                 break;
 }
 if (doorSensor == 0){
      do{
                 cout&lt;&lt;"Press (S) to Start,and close the Door."&lt;&lt;endl;
                 cin&gt;&gt;startPause;
                 cout&lt;&lt;"LED is On\n";
                 while(waterLevelSensor != waterLevel){
                             waterLevelSensor++;
                 }
                 while(tempSensor != temp){
                             tempSensor++;
                 }
                 cout&lt;&lt;"Washing Operation Started!               Time Left:"&lt;&lt;timeToWash&lt;&lt;endl;
                 cout&lt;&lt;"Washing with Soap Operation Started!\n";
                 timeToWash = timeToWash / 2 ;
                 cout&lt;&lt;"Rinsing Operation Started!               Time Left:"&lt;&lt;timeToWash&lt;&lt;endl;
                 timeToWash = timeToWash / 2 ;
                 cout&lt;&lt;"Drying Operation Started!               Time Left:"&lt;&lt;timeToWash&lt;&lt;endl;
                 timeToWash = 0 ;
                 startPause = 'P';
      }while((startPause == 's') || (startPause =='S'));
 }
 cout&lt;&lt;"End!\nLED is Off";
 return 0;
}


void manualMode(){
     cout&lt;&lt;"Enter Temperature: \n";
     cin&gt;&gt;temp;
     cout&lt;&lt;"Enter Time to wash: \n";
     cin&gt;&gt;timeToWash;
     cout&lt;&lt;"Choose Operation: (1)Water Only, (2)Water and Soap, (3)Rinse, (4)Dry, (5)All\n";
     cin&gt;&gt;operation;
}
void defaultMode(){
     int whatToWash;
     cout&lt;&lt;"Choose what to Wash: (1)Cups, (2)Plates, (3)Pots";
     cin&gt;&gt;whatToWash;
     switch(whatToWash){
          case 1:
                temp = 30;
                timeToWash = 3;
                break;
          case 2:
                temp = 40;
                timeToWash = 3;
                break;
          case 3:
                temp = 60;
                timeToWash = 3;
                break;
     }
 }
I would have some suggestions for improvements regarding C++ in general (I'm not familiar with embedded systems).

Indentation

Make sure to use uniform indentation across the code, in order to make it more readable. (E.g., the do-while loop, the switch-block in the main method should be at the same level as the declarations at the beginning.)

Code organization

It is very good, that manual mode and default mode are two separate functions. Breaking down the code makes it easier to read. I would also export some other parts to separate functions, especially the main cycle. (Remark: this is a generic principle. It might be that in the context of embedded systems there are some further considerations, which I'm not aware of, e.g. that code should be as fast as possible, for which this advice does not apply. Please consider this.)

Variable initialization

I would initialize each variable explicitly to some default value (e.g. 0), even if it is sure to be initialized later. In this way, you can for sure prevent undefined behavior (e.g., in case the code gets modified later, and a path is introduced where the variable is not initialized anymore).

Control flow

In the do-while loop for the washing-cycle, startPause is read, but then, at the end of the loop, it is set to a constant value (independently of what has been read). So this loop only runs once. I think either the whole logic should be removed, or improved in a way that looping really depends on the input value.

Input validation

In more places, input is required from the user, but it is never checked if it is within the range of the allowed values. In a production system this would be a must, but also in your case, I would clarify if this is required.