SlideShare uma empresa Scribd logo
1 de 2
//C++ program using class
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class Student
{
private:
int rollno;
char name[25];
float marks;
char grade;
public:
void readStudent()
{
cout<<"n Enter Roll no.:";
cin>> rollno;
cout<<"n Enter name :";
gets(name);
cout<<"n Enter marks :" ;
cin>> marks;
}
void dispStudent()
{
calcGrade();
cout<<"n Roll no. : "<<rollno;
cout<<"n Name :"<<name;
cout<<"n Marks :"<<marks;
cout<<"n Grade :";
}
int getRollno()
{
return rollno;
}
float getMarks()
{
return marks;
}
void calcGrade()
{
if (marks>=75)
grade='0';
else if (marks >=60)
grade = 'A';
else if (marks >=50)
grade='B';
else if (marks >=40)
grade ='C';
else
grade= 'F';
}
};
void main()
{Student XIIa[10];
for(int i=0; i<10; ++i)
{
cout<<"n Enter the details of student"<<i+1<<":";
XIIa[i].readStudent();
}
int choice, rno, pos=-1, highmarks=0;
do
{
clrscr();
cout<<"nnn Main menunn";
cout<<"n 1. Specific student";
cout<<"n 2. Topper";
cout<<"n 3. Exit ";
cout<<"n Enter your choice";
cin>> choice;
switch(choice)
{
case 1: cout<<"n Enter roll no. of student whose details you want to see:";
cin>>rno;
for(i=0; i<10; ++i)
{
if (XIIa[i].getRollno()==rno)
{XIIa[i].dispStudent();
break;
}
}
if (i==10)
cout<<"n INVALID ROLLNO.!!!!!!!!";
getch();
break;
case 2: for( i=0; i<10; ++i)
{
if(XIIa[i].getMarks()>highmarks)
{
pos=i;
highmarks=XIIa[i].getMarks();
}
}
XIIa[pos].dispStudent();
getch();
break;
case 3: break;
default: cout<<"n nnnnn WRONG CHOICE!!!!!!!!!!!!!nnnnnnn";
}
} while(choice>=1&& choice <3);
}

Mais conteúdo relacionado

Mais procurados

Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Dr. Loganathan R
 
Palindrome number program c
Palindrome number program cPalindrome number program c
Palindrome number program cmohdshanu
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Dr. Loganathan R
 
Basic program in java
Basic program in java Basic program in java
Basic program in java Sudeep Singh
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersDr. Loganathan R
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY MazedurMazedurr rahman
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Dr. Loganathan R
 
matlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesmatlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesRakesh kumar jha
 
MATLAB CODE OF Shifting sequence
MATLAB  CODE  OF Shifting sequenceMATLAB  CODE  OF Shifting sequence
MATLAB CODE OF Shifting sequenceRakesh kumar jha
 
11103500 61599 sagar (1)
11103500 61599 sagar (1)11103500 61599 sagar (1)
11103500 61599 sagar (1)Rounit Roy
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Dr. Loganathan R
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Syed Umair
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Dr. Loganathan R
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++Abhishek Pratap
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest DescentJeremy Lane
 
C program to add n numbers
C program to add n numbers C program to add n numbers
C program to add n numbers mohdshanu
 

Mais procurados (19)

Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
 
Palindrome number program c
Palindrome number program cPalindrome number program c
Palindrome number program c
 
Elf文件解析
Elf文件解析Elf文件解析
Elf文件解析
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
Basic program in java
Basic program in java Basic program in java
Basic program in java
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
matlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesmatlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequences
 
MATLAB CODE OF Shifting sequence
MATLAB  CODE  OF Shifting sequenceMATLAB  CODE  OF Shifting sequence
MATLAB CODE OF Shifting sequence
 
11103500 61599 sagar (1)
11103500 61599 sagar (1)11103500 61599 sagar (1)
11103500 61599 sagar (1)
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
MFC Polygon
MFC PolygonMFC Polygon
MFC Polygon
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest Descent
 
C program to add n numbers
C program to add n numbers C program to add n numbers
C program to add n numbers
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 

Semelhante a C++ program using class

Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsSwarup Boro
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfcontact32
 
CCE management system
CCE management systemCCE management system
CCE management systemTrish004
 
C++ programming structure & union
C++ programming structure & unionC++ programming structure & union
C++ programming structure & unionargusacademy
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Aman Deep
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)Aman Deep
 
bank management system
bank management systembank management system
bank management systemAisha Aisha
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMKrishna Raj
 
C programming structure & pointer
C  programming structure & pointerC  programming structure & pointer
C programming structure & pointerargusacademy
 
Csphtp1 09
Csphtp1 09Csphtp1 09
Csphtp1 09HUST
 
Write a class Runner that contains the following data members.docx
Write a class Runner that contains the following data members.docxWrite a class Runner that contains the following data members.docx
Write a class Runner that contains the following data members.docxzahid javed
 

Semelhante a C++ program using class (20)

Pointers
PointersPointers
Pointers
 
P1
P1P1
P1
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdf
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
CCE management system
CCE management systemCCE management system
CCE management system
 
C++ programming structure & union
C++ programming structure & unionC++ programming structure & union
C++ programming structure & union
 
Oop1
Oop1Oop1
Oop1
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
bank management system
bank management systembank management system
bank management system
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAM
 
L10
L10L10
L10
 
C programming structure & pointer
C  programming structure & pointerC  programming structure & pointer
C programming structure & pointer
 
3433 Ch09 Ppt
3433 Ch09 Ppt3433 Ch09 Ppt
3433 Ch09 Ppt
 
Csphtp1 09
Csphtp1 09Csphtp1 09
Csphtp1 09
 
Write a class Runner that contains the following data members.docx
Write a class Runner that contains the following data members.docxWrite a class Runner that contains the following data members.docx
Write a class Runner that contains the following data members.docx
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 

Mais de Swarup Boro

Concatenation of two strings using class in c++
Concatenation of two strings using class in c++Concatenation of two strings using class in c++
Concatenation of two strings using class in c++Swarup Boro
 
Array using recursion
Array using recursionArray using recursion
Array using recursionSwarup Boro
 
Binary addition using class concept in c++
Binary addition using class concept in c++Binary addition using class concept in c++
Binary addition using class concept in c++Swarup Boro
 
Study of Diffusion of solids in Liquids
Study of Diffusion of solids in Liquids                                 Study of Diffusion of solids in Liquids
Study of Diffusion of solids in Liquids Swarup Boro
 
Program using function overloading
Program using function overloadingProgram using function overloading
Program using function overloadingSwarup Boro
 
Program to sort array using insertion sort
Program to sort array using insertion sortProgram to sort array using insertion sort
Program to sort array using insertion sortSwarup Boro
 
Program to find the avg of two numbers
Program to find the avg of two numbersProgram to find the avg of two numbers
Program to find the avg of two numbersSwarup Boro
 
Program to find factorial of a number
Program to find factorial of a numberProgram to find factorial of a number
Program to find factorial of a numberSwarup Boro
 
Canteen management program
Canteen management programCanteen management program
Canteen management programSwarup Boro
 
Railway reservation
Railway reservationRailway reservation
Railway reservationSwarup Boro
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructorSwarup Boro
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functionsSwarup Boro
 
Structures in c++
Structures in c++Structures in c++
Structures in c++Swarup Boro
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++Swarup Boro
 

Mais de Swarup Boro (20)

Concatenation of two strings using class in c++
Concatenation of two strings using class in c++Concatenation of two strings using class in c++
Concatenation of two strings using class in c++
 
Array using recursion
Array using recursionArray using recursion
Array using recursion
 
Binary addition using class concept in c++
Binary addition using class concept in c++Binary addition using class concept in c++
Binary addition using class concept in c++
 
Study of Diffusion of solids in Liquids
Study of Diffusion of solids in Liquids                                 Study of Diffusion of solids in Liquids
Study of Diffusion of solids in Liquids
 
Program using function overloading
Program using function overloadingProgram using function overloading
Program using function overloading
 
Program to sort array using insertion sort
Program to sort array using insertion sortProgram to sort array using insertion sort
Program to sort array using insertion sort
 
Program to find the avg of two numbers
Program to find the avg of two numbersProgram to find the avg of two numbers
Program to find the avg of two numbers
 
Program to find factorial of a number
Program to find factorial of a numberProgram to find factorial of a number
Program to find factorial of a number
 
Canteen management program
Canteen management programCanteen management program
Canteen management program
 
Railway reservation
Railway reservationRailway reservation
Railway reservation
 
Boolean
BooleanBoolean
Boolean
 
Classes
ClassesClasses
Classes
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
Pointers
PointersPointers
Pointers
 
Queue
QueueQueue
Queue
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Stack
StackStack
Stack
 
Functions
FunctionsFunctions
Functions
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++
 

C++ program using class

  • 1. //C++ program using class #include<iostream.h> #include<stdio.h> #include<conio.h> class Student { private: int rollno; char name[25]; float marks; char grade; public: void readStudent() { cout<<"n Enter Roll no.:"; cin>> rollno; cout<<"n Enter name :"; gets(name); cout<<"n Enter marks :" ; cin>> marks; } void dispStudent() { calcGrade(); cout<<"n Roll no. : "<<rollno; cout<<"n Name :"<<name; cout<<"n Marks :"<<marks; cout<<"n Grade :"; } int getRollno() { return rollno; } float getMarks() { return marks; } void calcGrade() { if (marks>=75) grade='0'; else if (marks >=60) grade = 'A'; else if (marks >=50) grade='B'; else if (marks >=40) grade ='C'; else grade= 'F'; } }; void main() {Student XIIa[10]; for(int i=0; i<10; ++i) { cout<<"n Enter the details of student"<<i+1<<":"; XIIa[i].readStudent(); } int choice, rno, pos=-1, highmarks=0; do { clrscr(); cout<<"nnn Main menunn";
  • 2. cout<<"n 1. Specific student"; cout<<"n 2. Topper"; cout<<"n 3. Exit "; cout<<"n Enter your choice"; cin>> choice; switch(choice) { case 1: cout<<"n Enter roll no. of student whose details you want to see:"; cin>>rno; for(i=0; i<10; ++i) { if (XIIa[i].getRollno()==rno) {XIIa[i].dispStudent(); break; } } if (i==10) cout<<"n INVALID ROLLNO.!!!!!!!!"; getch(); break; case 2: for( i=0; i<10; ++i) { if(XIIa[i].getMarks()>highmarks) { pos=i; highmarks=XIIa[i].getMarks(); } } XIIa[pos].dispStudent(); getch(); break; case 3: break; default: cout<<"n nnnnn WRONG CHOICE!!!!!!!!!!!!!nnnnnnn"; } } while(choice>=1&& choice <3); }