获得)函数参数中的预期错误

时间:2018-01-04 05:52:47

标签: c++ structure

我正在尝试制作学生成绩单(约10名学生)

我收到1个错误,即" ERROR TESTING.CPP 18 :)预期"请查看代码并帮助我。

当我删除参数时,我得到25个错误。

我还没有被教过关于班级或工会的事。

我只知道结构。因此,请不要在结构之外提供解决方案。

#include<iostream.h > 
#include<conio.h > 
#include<stdio.h >
    struct subject
         {
            float phy, chem, maths, CS, eng;
         }ss;

struct student
{
    int rno;
    char name[40];
    char Mname[40];
    char Fname[40];
    subject marks;
};

void grade(student U[].marks)   // THIS BLOCK IS GIVING ERROR
{
    char Gphy, Gch, Gmath, GCS, Ge;
    // For Physics
    if (U.marks.phy >= 91 && U.marks.phy <= 100)
            Gphy = "A1";
    else if (U.marks.phy >= 81 && U.marks.phy <= 90)
            Gphy = "A2";
    else if (U.marks.phy >= 71 && U.marks.phy <= 80)
            Gphy = "B1";
    else if (U.marks.phy >= 61 && U.marks.phy <= 70)
            Gphy = "B2";
    else if (U.marks.phy >= 51 && U.marks.phy <= 60)
            Gphy = "C1";
    else if (U.marks.phy >= 41 && U.marks.phy <= 50)
            Gphy = "C2";
    else if (U.marks.phy >= 33 && U.marks.phy < 490)
            Gphy = "D";
    else if (U.marks.phy >= 21 && U.marks.phy <= 32)
            Gphy = "E1";
    else
            Gphy = "E2";
    // For Chemistry
    if (U.marks.chem >= 91 && U.marks.chem <= 100)
            Gchem = "A1";
    else if (U.marks.chem >= 81 && U.marks.chem <= 90)
            Gchem = "A2";
    else if (U.marks.chem >= 71 && U.marks.chem <= 80)
            Gchem = "B1";
    else if (U.marks.chem >= 61 && U.marks.chem <= 70)
            Gchem = "B2";
    else if (U.marks.chem >= 51 && U.marks.chem <= 60)
            Gchem = "C1";
    else if (U.marks.chem >= 41 && U.marks.chem <= 50)
            Gchem = "C2";
    else if (U.marks.chem >= 33 && U.marks.chem < 490)
            Gchem = "D";
    else if (U.marks.chem >= 21 && U.marks.chem <= 32)
            Gchem = "E1";
    else
            Gchem = "E2";
        // For Maths
    if (U.marks.math >= 91 && U.marks.math <= 100)
            Gmath = "A1";
    else if (U.marks.math >= 81 && U.marks.math <= 90)
            Gmath = "A2";
    else if (U.marks.math >= 71 && U.marks.math <= 80)
            Gmath = "B1";
    else if (U.marks.math >= 61 && U.marks.math <= 70)
            Gmath = "B2";
    else if (U.marks.math >= 51 && U.marks.math <= 60)
            Gmath = "C1";
    else if (U.marks.math >= 41 && U.marks.math <= 50)
            Gmath = "C2";
    else if (U.marks.math >= 33 && U.marks.math < 490)
            Gmath = "D";
    else if (U.marks.math >= 21 && U.marks.math <= 32)
            Gmath = "E1";
    else 
            Gmath = "E2";
        // For Computers
    if (U.marks.CS >= 91 && U.marks.CS <= 100)
            GCS = "A1";
    else if (U.marks.CS >= 81 && U.marks.CS <= 90)
            GCS = "A2";
    else if (U.marks.CS >= 71 && U.marks.CS <= 80)
            GCS = "B1";
    else if (U.marks.CS >= 61 && U.marks.CS <= 70)
            GCS = "B2";
    else if (U.marks.CS >= 51 && U.marks.CS <= 60)
            GCS = "C1";
    else if (U.marks.CS >= 41 && U.marks.CS <= 50)
            GCS = "C2";
    else if (U.marks.CS >= 33 && U.marks.CS < 490)
            GCS = "D";
    else if (U.marks.CS >= 21 && U.marks.CS <= 32)
            GCS = "E1";
    else
            GCS = "E2";
        // For English
    if (U.marks.eng >= 91 && U.marks.eng <= 100)
            Ge = "A1";
    else if (U.marks.eng >= 81 && U.marks.eng <= 90)
            Ge = "A2";
    else if (U.marks.eng >= 71 && U.marks.eng <= 80)
            Ge = "B1";
    else if (U.marks.eng >= 61 && U.marks.eng <= 70)
            Ge = "B2";
    else if (U.marks.eng >= 51 && U.marks.eng <= 60)
            Ge = "C1";
    else if (U.marks.eng >= 41 && U.marks.eng <= 50)
            Ge = "C2";
    else if (U.marks.eng >= 33 && U.marks.eng < 490)
            Ge = "D";
    else if (U.marks.eng >= 21 && U.marks.eng <= 32)
            Ge = "E1";
    else
            Ge = "E2";
 }

 void input(student A[45]) 
 {
    clrscr();
    int n;
    cout << "Enter number of Students present (max. 45 ) : ";
    cin >> n;
    char t;
    cout << "Student List (enter 0 to terminate)\n ";
    for (int i = 0; i < n; i++) {
            gotoxy(20, 5);
            cout << "====Student Number" << i + 1 << "====\n";
            cout << "Enter Student's name : ";
            gets(A[i].name);
            cout << "Enter Mother's name : ";
            gets(A[i].Mname);
            cout << "Enter Father's name : ";
            gets(A[i].Fname);
            cout << "Enter roll no. of Student :";
            cin >> A[i].rno;
            cout << "Get Ready to enter marks of each subject....\n";
            clrscr();
            gotoxy(20, 5);
            cout << "==== Marks section ====\n";
            gotoxy(20, 7);
            cout << "Physics    : ";
            gotoxy(20, 9);
            cout << "Chemistry  : ";
            gotoxy(20, 11);
            cout << "Maths     : ";
            gotoxy(20, 13);
            cout << "Computers : ";
            gotoxy(20, 15);
            cout << "English   : ";
            gotoxy(31, 7);
            cin >> A[i].marks.phy;
            gotoxy(31, 9);
            cin >> A[i].marks.chem;
            gotoxy(31, 11);
            cin >> A[i].marks.maths;
            gotoxy(31, 13);
            cin >> A[i].marks.CS;
            gotoxy(31, 15);
            cin >> A[i].marks.eng;
            cout << endl;
            cout << "Do you want to enter more? (y/n) : ";
            cin >> t;
            if (t == 'y' || t == 'Y') {
                    clrscr();
                    continue;
            } else if (t == 'n' || t == 'N')
                    break;
            else {
                    cout << "Invalid choice, continuing..\n";
                    continue;
            }
    }
}

void marks(student I[10])
 {
    cout << "Student Details";
    for (int q = 0; q <= 75; q++)
            cout << "=";
    cout << "R.no\tName\tP  C  M  E  CS  %age  Grade\n";
    for (q = 0; q <= 75; q++)
            cout << "=";
    cout << endl;
    for (int i = 0; i < 10; i++) {
            gotoxy(20, 5);
            cout << "====Student " << i << "====\n";
            cout << "Physics   : " << I[i].marks.phy << endl;
            cout << "Chemistry : " << I[i].marks.chem << endl;
            cout << "Maths     : " << I[i].marks.maths << endl;
            cout << "Computers : " << I[i].marks.CS << endl;
            cout << "English   : " << I[i].marks.eng << endl;
    }
    getch();
}

void main() 
{
    int ch = 0;
    while (ch != 4) {
            clrscr();
            student S[10];
            gotoxy(20, 5);
            cout << "Student Report \n";
            gotoxy(20, 7);
            cout << "1. Enter details\n";
            gotoxy(20, 8);
            cout << "2. Display report of a student via roll no.\n";
            gotoxy(20, 9);
            cout << "3. Display report of all students\n";
            gotoxy(20, 10);
            cout << "4. Exit\n";
            gotoxy(20, 11);
            cout << "Enter your choice [1-4] : ";
            cin >> ch;
            switch (ch) {
            case 1:
                    input(S);
                    break;
            case 4:
                    cout << "Exiting...........";
                    break;
            default:
                    cout << "Invalid choice.";
                    break;
            }
            getch();
    }
  }

2 个答案:

答案 0 :(得分:0)

void grade(student U[].marks)    // THIS BLOCK IS GIVING ERROR

这不是一个块,它是一个函数声明,它给出了一个错误,因为它不是有效的C ++。你需要声明一个参数及其类型,这不是你怎么做的。你的方式完全取决于你打算参数的类型,甚至不是很清楚。

答案 1 :(得分:0)

好的我修正了错误

空缺等级(学生U []。标记)替换为空缺等级(浮动G)