#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int i=0;
float avg=0;
class Student
{
private:
char name[30];
int roll_no;
int marks[5];
char stream[40];
public:
Student()
{
strcpy(name,"XYZ");
roll_no=0;
for(i=0;i<5;i++)
{
marks[i]=0;
}
strcpy(stream,"ABCD");
}
void getdata();
void putdata();
void ass_stream();
};
void Student::getdata()
{
cout<<"Enter name:";
gets(name);
cout<<endl<<"Enter roll number:";
cin>>roll_no;
cout<<endl<<"Enter marks of five subject:";
for(i=0;i<5;i++)
{
cin>>marks[i];
}
}
void Student::putdata()
{
cout<<endl<<"Name:"<<name;
cout<<endl<<"Roll number:"<<roll_no;
cout<<endl<<"Marks secured in five subject:";
for(i=0;i<5;i++)
{
cout<<marks[i]<<'\t';
}
cout<<endl<<"Stream:"<<puts(stream);
}
void Student::ass_stream()
{
int sum=0;
for(i=0;i<5;i++)
{
sum=sum+marks[i];
}
avg=(sum/5)*100;
if(avg>=96)
strcpy(stream,"Computer Science");
else if(avg>=91 && avg<96)
strcpy(stream,"Electronics");
else if(avg>=86 && avg<91)
strcpy(stream,"Mechanical");
else if(avg>=81 && avg<86)
strcpy(stream,"Electrical");
else if(avg>=75 && avg<81)
strcpy(stream,"Chemical");
else if(avg>=71 && avg<75)
strcpy(stream,"Civil");
else
strcpy(stream,"Not available!Too low marks.");
}
void main()
{
clrscr();
Student S[20];
for(i=0;i<20;i++)
{
S[i].getdata();
}
cout<<endl<<"Assigning stream:";
for(i=0;i<20;i++)
{
S[i].ass_stream();
}
cout<<endl<<"List of students:";
for(i=0;i<20;i++)
{
S[i].putdata();
}
getch();
}
#include<conio.h>
#include<stdio.h>
#include<string.h>
int i=0;
float avg=0;
class Student
{
private:
char name[30];
int roll_no;
int marks[5];
char stream[40];
public:
Student()
{
strcpy(name,"XYZ");
roll_no=0;
for(i=0;i<5;i++)
{
marks[i]=0;
}
strcpy(stream,"ABCD");
}
void getdata();
void putdata();
void ass_stream();
};
void Student::getdata()
{
cout<<"Enter name:";
gets(name);
cout<<endl<<"Enter roll number:";
cin>>roll_no;
cout<<endl<<"Enter marks of five subject:";
for(i=0;i<5;i++)
{
cin>>marks[i];
}
}
void Student::putdata()
{
cout<<endl<<"Name:"<<name;
cout<<endl<<"Roll number:"<<roll_no;
cout<<endl<<"Marks secured in five subject:";
for(i=0;i<5;i++)
{
cout<<marks[i]<<'\t';
}
cout<<endl<<"Stream:"<<puts(stream);
}
void Student::ass_stream()
{
int sum=0;
for(i=0;i<5;i++)
{
sum=sum+marks[i];
}
avg=(sum/5)*100;
if(avg>=96)
strcpy(stream,"Computer Science");
else if(avg>=91 && avg<96)
strcpy(stream,"Electronics");
else if(avg>=86 && avg<91)
strcpy(stream,"Mechanical");
else if(avg>=81 && avg<86)
strcpy(stream,"Electrical");
else if(avg>=75 && avg<81)
strcpy(stream,"Chemical");
else if(avg>=71 && avg<75)
strcpy(stream,"Civil");
else
strcpy(stream,"Not available!Too low marks.");
}
void main()
{
clrscr();
Student S[20];
for(i=0;i<20;i++)
{
S[i].getdata();
}
cout<<endl<<"Assigning stream:";
for(i=0;i<20;i++)
{
S[i].ass_stream();
}
cout<<endl<<"List of students:";
for(i=0;i<20;i++)
{
S[i].putdata();
}
getch();
}
No comments:
Post a Comment