#include <iostream>
using namespace std;
void Delete(int arr[],char arr2[],int size){
int num;
cout<<"\nEnter roll number to Delete: ";
cin>>num;
for(int i=0;i<size;i++){
if (arr[i]==num){
arr[i]==0;
cout<<"\nDeletion successful";
break;
}
}
}
void Update(int arr[],char arr2[],int size){
int num;
cout<<"\nEnter roll number to update: ";
cin>>num;
char new_grade;
cout<<"\nEnter new grade for student with roll number "<<num<<" : ";
cin>>new_grade;
for(int i=0;i<size;i++){
if (arr[i]==num){
arr2[i]==new_grade;
cout<<"\nUpdate successful";
break;
}
}
}
void Search(int arr[],char arr2[],int size,int n){
for(int i=0;i<size;i++){
if(n==arr[i]){
cout<<"\nRoll number "<<arr[i]<<" is present and has a grade of "<<arr2[i];
break;
}
else{
cout<<"\nThe roll number is not present";
}
}
}
int main()
{
int n;
cout<<"\nEnter number of student:";
cin>>n;
int roll_no[n];
char grades[n];
int i=0;
while(1){
cout<<"\nChoose an operation to perform:\n1. Insert\n2. Delete\n3. Update\n4. Search\n5. Exit\n";
int c;
cin>>c;
if (c==1){
cout<<"\nEnter roll number: ";
cin>>roll_no[i];
cout<<"\nEnter grade: ";
cin>>grades[i];
}
else if (c==2){
Delete(roll_no,grades,n);
}
else if (c==3){
Update(roll_no,grades,n);
}
else if (c==4){
int num;
cout<<"\nEnter roll number to search: ";
cin>>num;
Search(roll_no,grades,n,num);
}
else if (c==5){
break;
}
i++;
}
return 0;
}
Comments
Leave a comment