我的程序不要求输入

My program is not asking for input

本文关键字:输入 程序 我的      更新时间:2023-10-16

我正在编写一个程序,这是一个很长的程序,我刚刚开始。我刚刚测试了它的运行,请告诉我为什么它没有用户输入:

#include <iostream>
using namespace std;
struct courses{
    int CLO1, CLO2, CLO3, CLO4, CLO5;
    int tcounter;
};
int main(){
    cin.clear();
    courses C1;
    C1.CLO1;
    C1.CLO2;
    C1.CLO3;
    int counter = 0;
    char name;
    cout << "Enter your Name: ";
    cin >> name;
    cout << "For C1, we have three CLOs that CLO1,CLO2 and CLO3. CLO1 and CLO3 are linked to PLO1 and CLO2 is linked to PLO2 " << endl;
    cout << "Enter your marks in CLO1 for C1:(Out of 10) ";
    cin >> C1.CLO1;
    if (C1.CLO1 >= 5){
        counter++;
    }
    cout << "Enter your marks in CLO2 for C1:(Out of 10) ";
    cin >> C1.CLO2;
    if (C1.CLO2 >= 5){
        counter++;
    }
    cout << "Enter your marks in CLO3 for C1:(Out of 10) ";
    cin >> C1.CLO3;
    if (C1.CLO3 >= 5){
        counter++;
    }
    cout << counter;
    return 0;
}

据我说,程序很好。您需要更改的三件事:

  1. 从字符到字符串的名称变量类型
  2. C1.氯1;C1.氯二;C1.氯3;从代码中删除这些没有任何意义。
  3. 打印值并选中:P