- 2

#include<iostream> #include<cstdlib> using namespace std; class student{ int rno; char name[10]; int m[6],n; float avg; public:

Check the error and show the output

9th May 2019, 3:04 PM
kumaran
kumaran - avatar
2 Respostas
+ 5
it will be better if you include the code and not just paste it like this, users will be able to figure out your problem easily
9th May 2019, 3:50 PM
✳AsterisK✳
✳AsterisK✳ - avatar
- 2
#include<iostream> #include<cstdlib> using namespace std; class student{ int rno; char name[10]; int m[6],n; float avg; public: void print(); void calc(); }; void student::calc(){ int i,sum=0; string s1 ="divide by zero"; string s2 ="no.of sub exceeds maximum limit. max is 5"; string s3 ="enter the character between 0 to 100(both exclusively)"; try{ cout<<"enter the rno:"; cin>>rno; if(rno<=0){ throw s3; } cout<<"enter the name:"; cin>>name; cout<<"enter n:"; cin>>n; if(n>0&&n<6) { cout<<"enter n marks:"; for(i=0;i<n;i++){ cin>>m[i]; if(m[i]<=0||m[i]>100) throw s3; sum+=m[i]; } avg=sum/n; } else if(n==0) throw s1; else if(n>=6) throw s2; } catch(int i) { cout<<"rno excep"<<rno; exit(1); } catch(string str){ cout<<"string excep"<<str; exit(1); } void student::print() { cout<<rno<<endl<<name<<endl<<avg<<endl; } main() { student s[10]; int i,n; cout<<"enter the no.of students:"; cin>>n; cout<<"student details are:"; for(i=0;i<n;i++) s[i].print(); f
9th May 2019, 3:04 PM
kumaran
kumaran - avatar