Compiles okay, but doesn't run.
Hello, I've created this program and it all compiles correctly with no errors but once it has compiled it doesn't run, it won't come up in command prompt (I have used Visual C++ to create this).
Is there something in the code that could be stoping this or am I missing something?
By the way I have had to put the
Code:
system ( "PAUSE" );
return 0;
cause before command prompt would only appear for a split second and disappear, I don't know whether or not that is effecting this program, but all I know is that I haven't been able to write a program without it,
Code:
#include <stdlib.h>
#include <iostream>
#include <assert.h>
using namespace std;
int main (int argc, char* argv[])
{
int mark [6];
int MarksRead=0;
int total=0;
if ( argc !=7)
{
cerr <<"Usage:./a.out n1 n2 n3 n4 n5 n6\n";
exit (1);
}
while (MarksRead <6)
{
cin>> mark [MarksRead];
MarksRead++;
}
for (int i=0; i<6; i++)
{
mark[i] =atoi(argv [i+1]);
assert(0 <= mark[i] && mark [i] <=100);
}
for (int i=0; i < 6; i++)
{
total += mark[i];
}
cout <<"Average Mark Is: "<<total/6.0 << endl;
system ( "PAUSE" );
return 0;
}
any suggestions would be greatly appreciated, Karla.