class 12 computer project
TRANSCRIPT
-
7/25/2019 Class 12 Computer Project
1/26
1
Certificate
Name: Rohan Gupta
Class & Section: XII A
School: Lucknow Public School
Session: 2015-2016
This is to be certified to be the bonafide work of the student of
computer laboratory during academic session 2015-2016.
Project work is successfully completed in the computer practical for the
AISSCE.
As prescribed by CBSE in the year 2015-2016.
____________________ ___________________
Examiner`s Signature Teacher`s Signature
-
7/25/2019 Class 12 Computer Project
2/26
2
AcknowledgementI am extremely grateful and remain indebted to my teacher & guide Mrs. Narayani Singh forbeing a source of inspiration and for her constant support in the design, implementation and
evaluation of the project. I am thankful to her constant criticism and invaluable suggestion,
which benefitted us a lot while developing the project. She has been a constant source of
inspiration and motivation for hard work & has been very co-operative throughout this project
work.
I also express my gratitude to my principal, Ms. Bharti Gosain for providing us the
infrastructure to carry out the project and to all the staff members who were directly &
indirectly instrument in enabling us to stay committed for the project. At last I would like to
thank my parents who helped me in various ways with their unconditional support and
affection during the years and always being there for me. They inspired my every step ahead to
put in my best.
-
7/25/2019 Class 12 Computer Project
3/26
3
Contents
-
7/25/2019 Class 12 Computer Project
4/26
4
IntroductionThe C++ programming language was developed at AT&T Bell laboratories in the early 1980s by
Bjarne Stroustrup. He found C lacking for simulations and decided to extend the language by
adding features form his favorite language, Simula 67. Simula 67 was one of the earliest object
oriented language. Bjarne Stroustroup called it C with classesor New C during
development. The name C++ (pronounced C plus plus) was coined by Rick Mascitti where
++is the C increment operator. Ever since its birth, C++ evolved to cope with problems
encountered by users, and through discussions at AT&T. However, the maturation of the C++
language is attested by two recent events:
(i)The formation of an ANSI (American National Standard Institute)
And (ii) the publication of The Annotated C+ Reference
Manual by Ellis and Stroustrup.
Many other programming languages have been influenced by C++, including C#, Java, and
newer versions of C (after 1998).
-
7/25/2019 Class 12 Computer Project
5/26
5
Function Overloading
Program 1: To illustrate the working of Function Overloading. Calculating
interest amount.
#include
#include
void amount(float princ, int time, float rate)
{
cout
-
7/25/2019 Class 12 Computer Project
6/26
6
}
void amount(int time, float rate)
{
cout
-
7/25/2019 Class 12 Computer Project
7/26
7
amount(6,0.07F);
return 0;
}
OUTPUT:
-
7/25/2019 Class 12 Computer Project
8/26
8
Classes and Objects
Program 2: Using class to store price list of 5 items and to print the largest price
as well as the sum of all prices.
#include
#include
class ITEM {
int itemcode[5];
float it_price[5];
public:
void initialize(void);
float largest(void);
float sum(void);
void display_item(void);
};
void ITEM::initialize(void)
{
for(int i=0;i
-
7/25/2019 Class 12 Computer Project
9/26
9
}
float ITEM::largest(void)
{
float large=it_price[0];
for(int i=1;i
-
7/25/2019 Class 12 Computer Project
10/26
10
}
cout
-
7/25/2019 Class 12 Computer Project
11/26
11
break;
}
}
while(ch>=1&&ch
-
7/25/2019 Class 12 Computer Project
12/26
12
Program 3: To illustrate the working of a function returning an object.
#include
class Distance {
int feet, inches;
public:
void getdata(int f,int i)
{feet=f;inches=i;}
void printit(void)
{
cout
-
7/25/2019 Class 12 Computer Project
13/26
13
cout
-
7/25/2019 Class 12 Computer Project
14/26
14
Program 4: To illustrate order of constructor invocation
#include
#include
class Subject { int days;
int subjectno;
public:
Subject(int d=123,int sn=101);
void printsub(void)
{
cout
-
7/25/2019 Class 12 Computer Project
15/26
15
rollno=0;
marks=0.0;
}
void getval(void)
{
coutrollno>>marks;
cout
-
7/25/2019 Class 12 Computer Project
16/26
16
}
void print(void)
{
stud.print();
sub.printsub();
cout
-
7/25/2019 Class 12 Computer Project
17/26
17
Program 5: To illustrate the use of overloaded Constructor
#include
#include
class Deposit { long int principal;
int time;
float rate;
float total_amt;
public: Deposit();
Deposit(long p, int t, float r);
Deposit(long p, int t);
Deposit(long p, float r);
void calc_amt(void); void display(void); };
Deposit::Deposit()
{principal=time=rate=0.0;}
Deposit::Deposit(long p, int t, float r)
{ principal=p; time=t; rate=r;}
Deposit::Deposit(long p, int t)
{principal=p; time=t; rate=0.08;}
Deposit::Deposit(long p, float r)
{principal=p; time=2; rate=r;}
void Deposit::calc_amt(void)
{total_amt=principal+(principal*time*rate)/100;}
void Deposit::display(void)
{ cout
-
7/25/2019 Class 12 Computer Project
18/26
18
cout
-
7/25/2019 Class 12 Computer Project
19/26
19
Program 6:To show working of virtual base class.
#include#includeclass Base
{public:
int a;};
class D1:virtual public Base{
public:int b;
};class D2:virtual public Base
{public:
int c;};class D3:public D1,public D2
{public:
int total;};
int main(){
clrscr();D3 ob;ob.a=25;ob.b=50;ob.c=75;ob.total=ob.a+ob.b+ob.c;cout
-
7/25/2019 Class 12 Computer Project
20/26
20
Data File Handling
Program 7: To illustrate of working with multiple files simultaneously
#include
#include
#include
int main()
{
system("cls");
ifstream filin1, filin2;
filin1.open("Stuname.txt",ios::in);
filin2.open("Stumarks.txt",ios::in);
char line[80];
cout
-
7/25/2019 Class 12 Computer Project
21/26
21
cout
-
7/25/2019 Class 12 Computer Project
22/26
22
Program 8: To write and read a structure using write() and read()
function using a binary file
#include
#include
#include
#include
struct customer { char name[51];
float balance; };
int main()
{
system("cls");
customer savac;
strcpy(savac.name,"Toby Marshall");
savac.balance=213466.75;
ofstream fout;
fout.open("Saving",ios::out|ios::binary);
if(!fout)
{
cout
-
7/25/2019 Class 12 Computer Project
23/26
23
cout
-
7/25/2019 Class 12 Computer Project
24/26
24
Program 9: To append data in a file
#include
#include
class stu { int rollno;
char name[25];
char Class[4];
float marks;
char grade;
public:
void getdata()
{ coutrollno;
coutname;
coutClass;
coutmarks;
if(marks>=75) grade='A';
else if(marks>=60) grade='B';
else if(marks>=50) grade='C';
else if(marks>=40) grade='D';
else grade='F';
}
void putdata()
{
cout
-
7/25/2019 Class 12 Computer Project
25/26
25
int main()
{
ofstream fo("stu.dat", ios::app|ios::binary);
char ans='y';
while(ans=='y')
{
s1.getdata();
fo.write((char *) &s1,sizeof(s1));
cout
-
7/25/2019 Class 12 Computer Project
26/26
26
Progra