title: Validation in a C++ Program
body: <p>first of all thnx for trying to help me.....this is a part of my program......i want to know how to put validations while inputting the data in main()....thnx</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;iostream.h&gt;
  #include&lt;conio.h&gt;
    int i;
  
   class product           //start of class
      {
  
  
              int itemno;
              char name[100];
              char itemtype[50];
              float price;
              float quantity;
              float total;
  
  
              public:
  
              void addprod() ;
              void calculate();
              void accept();
              void display()   ;
  
  
  
  
       }    ;                 //end of class
  
  
  
  
       void product::addprod()   //starting of addproduct()
          {
              cout&lt;&lt;"enter the serial number";
              cin&gt;&gt;itemno;
  
              cout&lt;&lt;"enter the name of the poduct:";
              gets(name)   ;
  
              cout&lt;&lt;"enter its type:";
              gets(itemtype);
  
              ***cout&lt;&lt;"enter its price:";
              cin&gt;&gt;price;**
          }*                                       //end of addproduct()
  
  
  
       void product::accept()           //starting of accept()
       {
              cout&lt;&lt;"enter the item name:";
              gets(name)  ;
  
  
              cout&lt;&lt;"enter the quantity:";
              cin&gt;&gt;quantity;
  
       }
  
  
  
  
       void    product::calculate()
          {
                      total=price*quantity;
           }
  
  
  
       void product::display()
          {
                  cout&lt;&lt;"\nName";
                  cout&lt;&lt;name;
  
                  cout&lt;&lt;"\nPrice";
                  cout&lt;&lt;price ;
                  cout&lt;&lt;"\nquantity";
                   cout&lt;&lt;quantity;
                   cout&lt;&lt;"\ntotal\n\n\n\n\n";
                  cout&lt;&lt;total;
  
          }
  
  
  
  
  
          void main()
          {
           int ch;
           product s1[3];
  
           a:
  
           cout&lt;&lt;"\n      1.      Add product one by one";
           cout&lt;&lt;"\n     2.      Add products in bulk";
           cout&lt;&lt;"\n     3.      Make Bill";
           cout&lt;&lt;"\n     4.      Display Bill";
           cout&lt;&lt;"\n     0.      Exit";
           cout&lt;&lt;"\n     Enter your choise(1,2,3,9)"     ;
           cin&gt;&gt;ch;
  
  
           switch(ch)
           {
  
           **case 1:          cout&lt;&lt;"\n press n to exit\n\n";
                                  char con='y';
                                  while(con=='y')
                                  {
                                  s1[i].addprod();
                                  i++;
                                  cout&lt;&lt;"do u wanna continue(y/n)";
                                  cin&gt;&gt;con;
                                          if(con=='n')
                                          {
                                          goto a;
                               }
                                  }
                                  break;
              }**
  </code></pre>
  
  <p>This is my school project so need help as soon as possible.
  like if a person enters a character(a,b,c) so what should i do to make him aware its a wrong input and asks the user to input the correct form</p>