Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

C++
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;
}
Posted
Updated 9-May-18 7:56am

1 solution

id and name are only accessible from the input method; you'll have to make them accessible from output too, for example:
C++
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;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900