我的程序不是要求输入

时间:2017-01-07 06:57:01

标签: c++

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

#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 个答案:

答案 0 :(得分:0)

按照我的说法,程序很好。 你需要改变三件事:

  1. 从char到string的可变类型名称
  2. C1.CLO1; C1.CLO2; C1.CLO3;从你的代码中删除这些没有任何意义。
  3. 打印值并检查:P