Monday, May 24, 2010

Explain line by line the following C++ code?

#include %26lt;iostream.h%26gt;


#include %26lt;conio.h%26gt; //for getch()


#include %26lt;ctype.h%26gt; //for isdigit


#include %26lt;stdlib.h%26gt; //for atoi





main()








{


char ch;


char entier[6];


int compteur=0;


cout %26lt;%26lt; "Enter a whole number : ";


cout.flush ();


do





{


ch = getch();


if ( ch=='\b' %26amp;%26amp; compteur%26gt;0)








{


compteur--;


cout %26lt;%26lt;'\b';


cout %26lt;%26lt; ' ';


cout %26lt;%26lt;'\b';


cout.flush ();


}


else


if (compteur%26lt;6 %26amp;%26amp; isdigit(ch))








{


entier[compteur++]=ch;


cout%26lt;%26lt;ch;


cout.flush();


}


}


while(ch!='\r');


entier [compteur]='\0';


int valeur=atoi(entier);


cout %26lt;%26lt; "\nThe whole number is " %26lt;%26lt; valeur %26lt;%26lt; endl;








system("pause");


}

Explain line by line the following C++ code?
Hey that's not a very good question to ask here. We are here to help you, not serve you.


So instead of giving a junk code and ordering others to explain the damn code, point to the specific line and ask to explain that line. Hope you got my point.
Reply:Damn, that code is just hard enough to read that I couldn't be bothered trying to comprehend it. Damn Yahoo! answers for not keeping indentation.
Reply:hey are you reading Programming for Dummies? Because I'm reading it too


No comments:

Post a Comment