Untitled
unknown
plain_text
2 years ago
1.2 kB
6
Indexable
#include<iostream> #include<stdlib.h> using namespace std; void edit(); void input(); void display(); struct student{ string ID; string name; float cgpa; }; void input(student &stud){ cout<<"Enter your name : "; cin>>stud.name; fflush(stdin); cout<<"Enter your ID : "; cin>>stud.ID; cout<<"Enter your CGPA : "; cin>>stud.cgpa; } void display(student &stud){ cout<<"Name is : "<<stud.name<<endl; cout<<"ID is : "<<stud.ID<<endl; cout<<"CGPA is : "<<stud.cgpa<<endl; } void edit(student &stud){ int choice; cout<<"\nEnter 1 to edit ID\n2 to edit name\n3 to edit CGPA\nElse press 4 key to exit !!\n\nSo What u wanna do ?"<<endl; cin>>choice; switch(choice){ case 1: cout<<"Enter the new ID : "; cin>>stud.ID; display(stud); break; case 2: cout<<"Enter the new name : "; cin>>stud.name; display(stud); break; case 3: cout<<"Enter the new CGPA : "; cin>>stud.cgpa; display(stud); break; case 4: exit(0); default: cout<<"Please enter a correct choice"<<endl; edit(stud); break; } } int main(void){ student stud; input(stud); display(stud); edit(stud); }
Editor is loading...