Student data entry
It is the first day in school. The kids need to enroll their data in system. Teacher calls one by one to enter the data. They need to enter their data and need to check the display their details.
[Hint : use structure to store the details of student]
Answers
Answer:
include <iostream>
#include<cstring>
using namespace std;
struct student
{
char name[50];
int roll;
float marks;
};
int main()
{
struct student s;
cin.get(s.name, 50);
std::cin>>s.roll;
std::cin>>s.marks;
std::cout<<"Student Details"<< std::endl;
std::cout<<"Name: "<<s.name<<std::endl;
std::cout<<"Roll: "<<s.roll<<std::endl;
std::cout<<"Marks: "<<s.marks<<std::endl;
return 0;
//Your code goes here
}
Explanation:
Answer:
#include <iostream>
#include<string>
struct student
{
char name[50];
int roll;
int marks;
};
int main()
{
struct student s1;
std::cout<<"\nStudent Details"<<"\n";
// The \n before Student is very important or else no test case will pass
std::cin.getline(s1.name,50);
std::cin>>s1.roll; std::cin>>s1.marks;
std::cout<<"Name: "<<s1.name<<"\n"<<"Roll: "<<s1.roll<<"\n"<<"Marks: "<<s1.marks<<"\n";
}
Explanation: