I started out with 15 errors and worked them all out except for this one.
"error C2144: syntax error : 'int' should be preceded by ';'"
it points to my int main ()
I tried look for any missing ";" but cant find any.
Would any one mind taking a look?
It a program filling a random number in all the array locations and asking user to enter an integer (between 0 and 9) and we are supposed to print score.
Code:// pointer to arrays #include <iostream> #include <ctime> using namespace std; void printarray () int main ( ) { int score [10]; int *ptr; int userint = 0; ptr = &score[0]; //ptr poinst to the integer array of "score" srand(time(NULL)); ////makes use of the computer's internal clock to control the choice of the seed. //for loop will loop filing with random numers between 0 and 50 for (int i = 0; i < 10; i++) { *ptr = rand()%50; ++ptr; } cout << "Enter a number between 0 and 9: " ; cin >> userint; //if else stament determines if use data is between 0 and 9 if (userint >= 0 && userint <= 9) cout << score[userint] << endl; else if (userint > 10 ) cout <<"You must enter a number between 0 and 9, Please try again." << endl; system ("pause"); return 0; }



LinkBack URL
About LinkBacks


