can you continue it??this is a c++ program using c++ in a stack
#include %26lt;iostream.h%26gt;
#define max5
main()
{
char stack [max];
cout%26lt;%26lt;"populating array of records:"
for ( i=0 ,i=max-1,i++)
{
cout%26lt;%26lt;"enter array:"%26lt;%26lt;i;
cin %26gt;%26gt;"stack[i]
}
return (0);
C++ (stack)?
By "continue" do you mean get it to compile and run? :-)
#include %26lt;iostream.h%26gt;
// 1.) missing space
#define max 5
main()
{
char stack [max];
// 1.) doesn't this line need a semi-colon?
cout%26lt;%26lt;"populating array of records:"
// 1.) i is undeclared
// 2.) semi-colon (not comma) delimits
// expressions in for statement
// 3.) expression to limit for loop
// should read, "i is less than
// max" (not "i equals max")
// 4.) in the loop as shown below, the value
// of i will only reach (max - 1); if you explicity
// subtract 1 from that limit, you will leave
// one element unprocessed.
int i;
for ( i = 0; i %26lt; max; i++)
{
cout%26lt;%26lt;"enter array:"%26lt;%26lt;i;
// 1.) missing semi-colon
// 2.) that double-quote can't possibly
// be right either
cin %26gt;%26gt;stack[i];
}
return (0);
// 1.) function main() missing closing
// squiggly bracket
}
I did not attempt to compile this... I'm reasonably sure it will though, as shown. I practically never use the i/o stream stuff, so I have no expectations as to how this will look in the console... likely needs some new lines added to the output, at minimum.
sweet pea
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment