/* PROGRAM - 2
Define a class Student with the following members:
Private members :
rollno, name, marks[5] and stream.
Assignstream ( ) - to assign stream according to the condition given below
If percentage > = 95, stream =Electronics
If percentage >=80 & < 95 , =Computer Science
If percentage >=60 & < 80 , =Civil
Otherwise - Not allotted
Public Members :
void getstud ( ) - to input data members except stream.
Void putstud ( ) - to display all data members.
Write a program to implement this class for an array of 3 students.*/
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>
class Student
{
int rollno ;
char name [ 20 ];
float marks [ 5 ] ;
char stream [ 20 ] ;
float calculate ( );
void assignstream ( )
{
float p = calculate ( ) ;
p = p / 5;
if ( p >= 95 )
strcpy ( stream , "Electronics" );
else if ( p >= 80 )
strcpy ( stream , "Computer Science");
else if ( p >=60)
strcpy ( stream , "Civil");
else
strcpy ( stream , "Not Allotted");
}
public :
void getstud ( );
void putstud ( );
};
float Student::calculate()
{
float s =0.0 ;
for ( int i = 0 ; i < 5 ; ++i )
s += marks [ i ] ;
return s ;
}
void Student::getstud()
{
cout <<"\n\n Enter Rollno : ";
cin >> rollno;
cout<<"\n Enter The name of the Student : ";
gets( name ) ;
cout<<"\n Enter Marks in 5 Subjects : ";
for ( int i = 0 ; i < 5 ; ++i )
{
cout<<"\n Subject "<<i+1<<" : ";
cin >> marks [ i ] ;
}
assignstream( ) ;
}
void Student::putstud()
{
cout <<"\n Rollno = "<<rollno;
cout <<"\n\n Name = "; puts( name ) ;
cout <<"\n Marks : \n";
for ( int i = 0 ; i < 5 ; ++i )
{
cout<<" Subject "<<i+1<<" : "<<marks [i] <<" ";
}
cout <<"\n\n Total Marks="<< calculate ( ) ;
cout <<"\t\t Stream = "<<stream;
}
void main ( )
{
clrscr ( ) ;
Student s [ 3 ] ;
cout<<"\n\t\t Enter Details of 3 Students : \n";
for ( int i = 0 ; i < 3 ; ++i )
s [ i ]. getstud ( ) ;
for ( i = 0 ; i < 3 ; ++i )
s [ i ]. putstud ( ) ;
getch ( );
}
bhai program me error hai mr. naidu
ReplyDeleteSorry There is No error!!!!
DeleteTheir r 6 errors in ur program
ReplyDeleteSend Screenshot of ur program
DeleteThere is No error Bro!!!!