嘿所以我从我的大学那里得到了一个旧的测验,我尝试了他们使用的相同答案,但我得到了错误 [英] Hey so I have the old quiz from my universtiy and I try the same answer they use but I got error
问题描述
嘿所以问题是:
写两个函数一个输入和其他输出
在c ++编程中使用studentid和
studentname
void input();
void output();
输出:
输入studentid:123
输入学生名称:Mohammed
学生ID是:123
学生姓名是穆罕默德
这样的测验中的问题,答案就像是这但我得到错误我不知道答案是不正确还是不完整可以帮助
我尝试了什么: < br $> b $ b
Hey so the question is :
Write two function one input and other output
In c++ programming taking studentid and
studentname
void input();
void output();
Output:
Enter the studentid: 123
Enter the studentname: Mohammed
The student id is : 123
The student name is Mohammed
the question in the quiz like this , and the answer was like this but i got error i have no idea if the answer was not correct or not full can you help
What I have tried:
void input()
{
int id;
char name[20];
cout<<"Enter the student id:"<<endl;
cin>>id;
cout<<"Enter the student name:"<<endl;
cin>>name;
}
void output()
{
cout<<"The Student id is: "<< id <<endl;
cout<<"The Student name is: "<< name <<endl;
}
推荐答案
id
和名称
只能从输入
方法访问;您还必须从输出
访问它们,例如:
id
andname
are only accessible from theinput
method; you'll have to make them accessible fromoutput
too, for example:
int id;
char name[20];
void input()
{
cout<<"Enter the student id:"<<endl;
cin>>id;
cout<<"Enter the student name:"<<endl;
cin>>name;
}
void output()
{
cout<<"The Student id is: "<< id <<endl;
cout<<"The Student name is: "<< name <<endl;
}
这篇关于嘿所以我从我的大学那里得到了一个旧的测验,我尝试了他们使用的相同答案,但我得到了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!