Hey guys, this is my first semester in C++ and i'm not grasping the whole thing yet. It's errors like these that have me ripping my hair our because I'm not able to find out where it went wrong. This is my first post so if i posted it in the wrong section, please advise and ill follow instructions accordingly.
#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>
usingnamespace std;
int AddStudM (int Studm[], int MaxM=1000);
// prototypes above.
int main ()
{
int loop=1;
int choice;
while (loop==1)
{
system ("CLS");
cout << " ** MENU **\n\n"
<< "0. Exit \n"
<< "1. Add Student mark \n"
<< "2. List all student marks \n"
<< "3. Calculate the marks average \n"
<< "4. Calculate the standard deviation \n"
<< "5. Delete a student mark \n"
<< "6. find the number of students via mark \n"
<< "7. Display distinct marks and their occurrences \n";
cout << "\n\nSelect from the menu above: ";
cin >> choice;
switch(choice)
{
case 0:
cout << "Good bye\n\n";
system ("pause");
exit(0);
case 1:
system ("CLS");
int AddStudM (int Studm[], int MaxM);
system ("pause");
system ("CLS");
main();
break;
case 2:
system("CLS");
cout << "\t-- List all student marks --\n\n";
system ("pause");
system("CLS");
break;
case 3:
system("CLS");
cout << "\t-- Calculate the marks average --\n\n";
system ("pause");
system("CLS");
break;
case 4:
system("CLS");
cout << "\t-- Calculate the standard deviation --\n\n";
system ("pause");
break;
case 5:
system("CLS");
cout << "\t-- Delete a student's mark --\n\n";
system ("pause");
system("CLS");
break;
case 6:
system("CLS");
cout << "\t-- Find the number of students via a mark --\n\n";
system ("pause");
system("CLS");
break;
case 7:
system("CLS");
cout << "\t-- Display distinct marks and their occurrences --\n\n";
system ("pause");
system("CLS");
break;
}
}
{
// 1. Add a student mark!
int AddStudM (int Studm[], int MaxM=1000);
int Mark;
int i;
for (i=0; i< MaxM; i++);
{
cout << "enter mark for student: ";
cin >> Mark;
Studm[i]=Mark;
}
i++;
return 0;
}
}
There error i received was
In function `int main()':
98 - Try.cpp `MaxM' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
102- Try.cpp `Studm' undeclared (first use this function)
I still get the exact same error...
I've tried removing from prototype and keep in definition...
Remove from definition and keep in prototype
Remove both
Keep both
In function 'int AddStudM(int*,int)':
94- default argument given for parameter 2 of 'int AddStudM(int*,int)'
8- after previous specification in 'int AddStudM(int*, int)'
#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>
usingnamespace std;
int MaxM=1000; //change
int Studm[1000]; //change
int AddStudM ();
// prototypes above.
int main ()
{
int loop=1;
int choice;
while (loop==1)
{
system ("CLS");
cout << " ** MENU **\n\n"
<< "0. Exit \n"
<< "1. Add Student mark \n"
<< "2. List all student marks \n"
<< "3. Calculate the marks average \n"
<< "4. Calculate the standard deviation \n"
<< "5. Delete a student mark \n"
<< "6. find the number of students via mark \n"
<< "7. Display distinct marks and their occurrences \n";
cout << "\n\nSelect from the menu above: ";
cin >> choice;
switch(choice)
{
case 0:
cout << "Good bye\n\n";
system ("pause");
exit(0);
case 1:
system ("CLS");
int AddStudM (int Studm[], int MaxM);
system ("pause");
system ("CLS");
main();
break;
case 2:
system("CLS");
cout << "\t-- List all student marks --\n\n";
system ("pause");
system("CLS");
break;
case 3:
system("CLS");
cout << "\t-- Calculate the marks average --\n\n";
system ("pause");
system("CLS");
break;
case 4:
system("CLS");
cout << "\t-- Calculate the standard deviation --\n\n";
system ("pause");
break;
case 5:
system("CLS");
cout << "\t-- Delete a student's mark --\n\n";
system ("pause");
system("CLS");
break;
case 6:
system("CLS");
cout << "\t-- Find the number of students via a mark --\n\n";
system ("pause");
system("CLS");
break;
case 7:
system("CLS");
cout << "\t-- Display distinct marks and their occurrences --\n\n";
system ("pause");
system("CLS");
break;
}
}
} //change
// 1. Add a student mark!
int AddStudM () //change
{
int Mark;
int i;
for (i=0; i< MaxM; i++);
{
cout << "enter mark for student: ";
cin >> Mark;
Studm[i]=Mark;
}
i++;
return 0;
}
]
at least it compiles now, but inputting numbers seems to error