Write a program with a function called studentDetails to print the name, age, se
ID: 3761771 • Letter: W
Question
Write a program with a function called studentDetails to print the name, age, section of a student when called. Call the function 4 times with 4 different sets of data. The program should have the following: a) A function called studentDetails with three arguments (of relevant datatypes). It does not return a value b) the main function which calls the above 4 times with 4 different sets of data. Here is what I have so far.
#include <iostream>
using namespace std;
void StudentDetails(){
int age = 0;
char name = “ “;
char section = “ “;
return;
}
int main(){
studentDetails (“Semper Gumbi”, 12, ‘A’);
studentDetails (“John Cena”, 13, ‘B’);
studentDetails (“Mr Snuffy “, 14, ‘C’);
studentDetails (“Buk Lao “, 15, ‘D’
cout << "age: " << age << endl;
cout << "Name : " << name << endl;
cout << "Section: " << Section << endl;
return 0;
}
Explanation / Answer
#include<iostream>
using namespace std;
void studentDetails(string name,int age,char section){
cout << "age: " << age << endl;
cout << "Name : " << name << endl;
cout << "Section: " << section << endl;
}
int main(){
studentDetails ("Semper Gumbi", 12, 'A');
studentDetails ("John Cena", 13, 'B');
studentDetails ("Mr Snuffy ", 14, 'C');
studentDetails ("Buk Lao ", 15, 'D');
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.