Tuesday 24 April 2018

OOPs Terminologies


June-2018

* A Constructor is a member function with the same name as that of its class and it is used to initialize the object of that class type with a legal initial value.

* Constructors are automatically invoked by the compiler.

* A Destructor is a member function with the same name as that if its class but is preceded by a tilde(~) and it is used deinitializes an object.

 link: https://www.youtube.com/watch?v=X_yruQkVGUs

C++ can constructor be private
In C++, constructor is automatically called when object of a class is created. ... With the Named Constructor Idiom, you declare all the class's constructors in theprivate or protected sections, and then for accessing objects of class, you create public static functions.

Can a constructor be private in C++ ? 

https://www.geeksforgeeks.org/can-constructor-private-cpp/


Constructor OverloadingConstructor can beoverloaded in a similar way as function overloading.Overloaded constructors have the same name (name of the class) but different number of arguments. Depending upon the number and type of arguments passed, specific constructor is called.

C++ Programming Default Arguments (Parameters) - Programiz

https://www.programiz.com/cpp-programming/default-argument
In C++ programming, you can provide default values for function parameters. The idea behind default argument is simple. If a function is called by passing ...

*How does a class enforce data-hiding, abstraction, and encapsulation?

A class binds together data and its associated functions under one unit thereby enforcing encapsulation as encapsulation means wrapping up data and associated functions together into a single unit.

A class groups its members into three sections: private, protected and public. The private and protected members remain hidden from outside world. Thus through private and protected members, a class enforces data-hiding.

The outside world is given only the essential and necessary information through public members, rest of the things remains hidden, which is nothing but abstraction. As abstraction means representation of essential features without including the background details or explanation.


Enlist some advantages of opp.
         i.            Reusability of code
       ii.            Ease of comprehension
      iii.            Ease of fabrication and maintenance
     iv.             Easy redesign and extension

Monday 23 April 2018

12th D Computer Science April Monthly Test 2018- Blue Print

Max Marks : 25                                                                          Duration: 01 Hour

1. Naming Identifier and Keyword                         - 02 marks
2. Naming Header files for the built in function.    - 01 marks
3. Syntax Error finding                                             -02 makrs
4. Output finding : Pointer concept                          -03 marks
5. Output finding: Array of characters                     -03 marks
6. Output finding : Random numbers                      -03 marks

7. Direct Questions(OOPs)
    Terminologies: (Data Hiding, Data Abstraction, Data Encapsulation, Class & Objects,
                             Polymorphism, Inheritance.)
            a) Terminology-I                                          -02 marks
            b) Terminology-II                                        - 02marks
             c) Terminology-III                                      -03 marks
8. Class Writing problem with the help of description - 04 marks


                                Good Luck

Tuesday 17 April 2018

12-D Prg-4 Class Hotel program

/* Define a class Hotel with following description private members RNo. of int, name of string, tariff(float), nod (number of days) of int. Cal() function to calculate and return amount as number of days.

if the value of  nod*tariff > 1000 then amount= 1.05* nod *tariff.
  */

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class hotel
{
int rno ;
float amount;
char name[50];
float tarrif;
int nod;
void calc() ;
public:
void checkin();
void checkout();
};
void hotel::calc ()
{ if(nod*tarrif>=1000)
{amount=1.05*nod*tarrif;
 cout << "\nThe amount is " ;
 cout << amount ;
 getch() ;
 }
else
{
amount=nod*tarrif;
cout<<"\n amount is:";
cout << amount ;
getch() ;
}

}
void hotel::checkin()
{

cout<<"\n enter room no.";
cin>>rno;
cout<<"\n enter name :";
gets(name);
cout<<"enter tariff :";
cin>>tarrif;
cout<<"\n entet the no. of days:";
cin>>nod;

}
void hotel:: checkout()
{

cout<<"\nthe room no is"<<rno;
cout<<"\n the name is:";
puts(name);
cout<<"\n tariff is:"<<tarrif;
cout<<"\n no. of days is:"<<nod;
calc();
}
void main ()
{
clrscr ();
hotel x ;
x.checkin();
x.checkout();
}

12-D Prog-3 Define a class Travel Plan

Define a class Travel Plan for the following description

/*12-C Prog-3 Define a class Travel Plan
private:
Tcode int
Tname string
Source string
Destination string
Distance float
Fare int

->Function Calfare() which calculates and returns fare according to following
criteria.

Distance    Fare
<= 1000      500
> 1000 and <=2500        750
>2500  100

public:
->Function ReadData() to read the data members and
  call function Calfare() to calculate fare;
->Function ShowData() to print the values of all the data members.*/

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class TravelPlan
{
   int Tcode;
   char Tname[20];
   char Source[30];
   char Destination[30];
   float Distance;
   int Fare;

   int calFare();

   public:
   void ReadData();
   void ShowData();
};
int TravelPlan :: calFare()
{
  if(Distance <= 1000)
   return 500;
  else  if(Distance <= 2500)
   return 750;
  else
   return 1000;
}
void TravelPlan :: ReadData()
{
  cout<<"\n Enter Travel code \n";
  cin>>Tcode;
  cout<<"\n Enter Travel Name ";
  gets(Tname);
  cout<<"\n Enter Source\n";
  gets(Source);
  cout<<"\n Enter Destination \n";
  gets(Destination);
  cout<<"\n Enter Distance \n";
  cin>>Distance;
  Fare=calFare();
}
void TravelPlan :: ShowData()
{
  cout<<"\n Travel Code "<<Tcode;
  cout<<"\n Travel Name "<<Tname;
  cout<<"\n Travel source "<<Source;
  cout<<"\n Destination "<<Destination;
  cout<<"\n Distance"<<Distance;
  cout<<"\n Fare"<<Fare;
}

void main()
{
   clrscr();
   TravelPlan T;
   T.ReadData();
   T.ShowData();
   getch();
}

12-D Prog-2 Define a struct employee to store employee code, employee name, address, phone no., salary. Create 5 objects of employee type read their values and print in ascending order of salary */


/*12-C Prog-2 Define a struct employee to store employee code, employee
name, address, phone no., salary.  Create 5 objects of employee type
read their values and print in ascending order of salary */

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>


struct employee
{
  int empcode;
  char empname[30];
  char adress[40];
  long phone;
  float salary;
};

void read(employee &E)
{
  cout<<"\n Enter employee code";
  cin>>E.empcode;
  cout<<"\n Enter employee name";
  gets(E.empname);
  cout<<"\n Enter employee's address";
  gets(E.adress);
  cout<<"\n Enter employee's phone no";
  cin>>E.phone;
  cout<<"\n Enter salary";
  cin>>E.salary;
}

void Arrange(employee E[], int size)
{
   int i,j;
   employee T;
   for(i=0;i<size;i++)
   {
     for(j=i+1;j<size;j++)
     {
       if(E[i].salary > E[j].salary)
       {
  T=E[i];
  E[i]=E[j];
  E[j]=T;
       }
     }
   }
}

void print(employee E)
{
  cout<<"\n Employee code"<<E.empcode;
  cout<<"\n Employee Name";
  puts(E.empname);
  cout<<"Employee Adress";
  puts(E.adress);
  cout<<"\n Employee Phone no"<<E.phone;
  cout<<"\n Employee salary"<<E.salary;
}

void main()
{
  clrscr();
  employee emp[5];
  cout<<"\n Enter details of Employee";
  for(int i=0; i<5; i++)
  {
    cout<<"\n Enter details of employee";
    read(emp[i]);
  }
  Arrange(emp,5);
  cout<<"\n Employees according to ascending order of salary\n";

  for(i=0;i<5;i++)
  {
     cout<<"\n Employee"<<i+1;
     print(emp[i]);
  }
 getch();
}

12D-Prg-1-Write a Program to define a class myarray.

12D-Prg-1-Write a Program to define a class myarray.

12C-Prg-1-Write a Program  to define a class myarray. which reads n elements of int type.  Write
4 member functions
1. input();
2.output();
3.large();  //  largest element logic
4.small(); // smallest element logic

#include<iostream.h>
#include<conio.h>

class myarray
{ int a[50],l,i,n,s;

  public:
  void input();
  void large();
  void small();
  void output();
};
void myarray::input()
{
  cout<<"enter no. of elements=";
  cin>>n;
  cout<<"\nenter the elements";
  for(i=0;i<n;i++)
  cin>>a[i];
}
void myarray::large()
{
  l=a[0];
  for(i=1;i<n;i++)
  { if(l<a[i])
    l=a[i];
  }
}
void myarray::small()
{
  s=a[0];
  for(i=1;i<n;i++)
  { if(s>a[i])
    s=a[i];
  }
}
void myarray::output()
{
 cout<<"\nlargest ="<<l;
 cout<<"\nsmallest="<<s;
}

void main()
{
clrscr();
myarray obj1;
obj1.input();
obj1.large();
obj1.small();
obj1.output();
getch();
}

12th CS CLASS PRACTICAL LIST 2018-19

12th CLASS PRACTICAL LIST

April-May

1.       Define a class my array to find the largest and smallest element using member functions.
2.       Define a structure employee to store employee code, employee name, address, phone number and salary. Create objects of employee type and read and display their details according to the sorted order of their salary.
3.       To display the details of a class Travel using classes and objects.
4.       To display the details of the class Hotel using classes and Objects.

June

5.       Write a program to show the working of all types of Constructors and Destructors.
6.       Write a program to print the Fibonacci series using Copy constructor.
July
7.       Simulation of Banking system using inheritance.
8.       Write a Program to calculate the number of vowels in a file using data file handling.
9.       Give a file student.dat that stores the details of some students. These details include roll number, name, class and marks in 5 subjects. Using the details in this file create another file called result.dat, which should store fields roll number, percentage and Grade. Grade must be assigned according to the following criteria.
Percentage
Grade
>=75
A
>=60 && <75
B
>=50 && <60
C
>=40 && <50
D
<40
E

10.   Write a program to create a file by accepting data fropm the user and make a menu driven program as given below
·         Char by Char
                                                         i.            Number of Character
                                                       ii.            Number of Blank Spaces
                                                      iii.            Number of Vowels
                                                     iv.            Number of specific character input by the user
·         Word by Word
                                                         i.            Number of Words
                                                       ii.            Number of a specific word input by the user
·         Line by Line
                                                         i.            Number of lines
                                                       ii.            Number of Lines starting with a specific character input by the user
11.   Write a Program to Illustrate the use of this Pointer.
12.   Write a Program to print the address and value at address by using the concept of array of pointers.
13.   Write a Program to implement Linear search using a 1-d array.
14.   Write a Program to implement Binary search using a 1-D array.
15.   Write a Program to implement selection sort using a 1-D array.
16.   Write a Program to implement Bubble sort using a 1-D array.
17.   Write a Program to implement Insertion Sort using a 1-D array.
18.   Write a Program to implement Stack using an array.
19.   Write a Program to implement Queue using an array.
20.   Write a Program to implement Stack using Linked Lists.
21.   Write a Program to implement queue using Linked.
22.   Write a Program to implement circular queue using an array.
SQL PRACTICALS
1.       Given the following tables for a database LIBRARY :
Book_Id
Book_Name
Author_Name
Publishers
Price
Type
Quantity
C0001
Fast Cook
Lata Kapoor
EPB
355
Cookery
5
F0001
The Tears
William Hopkins
First Publishers
650
Fiction
20
T0001
My First C++
Brain and Brooke
EPB
350
Text
10
T0002
C++ Brainworks
A. W. Rossaine
TDH
350
Text
15
F0002
Thunderbolts
Annaborts
First Publishers
750
Fiction
50
Table:ISSUED
Book_Id
Quantity_Issued
T0001
4
C0001
5
F0001
2

Write SQL queries for (a) to (f):
a)      To show Book name, Author name and Price of books of First Publishers.
b)      To list the names from books of Text type.
c)       To display the names and price of all books in ascending order of their price.
d)      To increase the price of all books of EPB Publishers by 50.
e)      To display the Book_Id, Book_Name and Quantity_Issued for all books which have been issued.
f)       To insert a new row in the table ISSUED having the following data : “F0003”,1
g)      Give the output of the following queries based on the above tables:
                                 i.            Select count(*) from BOOKS;
                               ii.            Select max(Price) from BOOKS where Quantity>=15;
                              iii.            Select Book_Name, Author_Name from BOOKS where Publisher=”EPB”;
                             iv.            Select count(distinct Publishers) from BOOKS where Price>=400;

2.       Given the following tables for a database FURNITURE:
Table: FURNITURE
No
Itemname
Type
Dateofstock
Price
Discount
1
White lotus
Double bed
23/02/02
30000
25
2
Pink feather
Baby cot
20/01/02
7000
20
3
Dolphin
Baby cot
19/02/02
9500
20
4
Decent
Office table
01/01/02
25000
30
5
Comfort zone
Double bed
12/01/02
25000
25
6
Donald
Baby cot
24/02/02
6500
15
7
Royal finish
Office table
20/02/02
18000
30
8
Royal tiger
Sofa
22/02/02
31000
30
9
Econo sitting
Sofa
13/12/01
9500
25
10
Eating paradise
Dining table
19/02/02
11500
25

Table : Arrivals
No
Itemname
Type
Dateofstock
Price
Discount
11
Wood comfort
Double bed
23/03/03
25000
25
12
Old fox
Sofa
20/02/03
17000
20
13
Micky
Baby cot
21/02/03
7500
15

Write SQL queries for (a) to (f):
a)      To show all information about Baby cots from the FORNITURE table.
b)      To list the Itemname which are priced more than 15000 from the FURNITURE table.
c)       To list the Itemname and Type of those items, in which Dateofstock is before 22/01/02 from the FURNITURE table in descending order of Itemname.
d)      To display the Itemname and Dateofstock of those items, in which Discount percentage is more than 25 from FURNITURE table.
e)      To count the number of items, whose Type is “Sofa” from FURNITURE table.
f)       To insert a new row in the ARRIVALS table with the following data :
           14, “Velvet touch”, “Double bed”, {25/03/03}, 25000, 30
g)      Give the output of the following SQL statements :
                                 i.            Select count(distinct Type) from FURNITURE;
                               ii.            Select max(Discount) from FURNITURE;
                              iii.            Select avg(Discount) from FURNITURE where type=”Baby cot”;
                             iv.            Select sum(price) from FURNITURE where Dateofstock<{12/02/02}.
3.       Given the tables EMPLOYEE and SALARY. Write SQL commands for the statements (i) to (iv) and Give outputs for SQL queries (v) to (vi):
Table: EMPLOYEE
Eid
Name
Depid
Qualification
Sex
1
Deepali Gupta
101
M.C.A
F
2
Rajat Typagi
101
B.C.A
M
3
 Hari Mohan
102
B.A
M
4
Harry
102
M.A
M
5
Sumit Mittal
103
B.Tech
M
6
Jyoti
101
M.Tech
F
Table:SALARY
Eid
Basic
DA
HRA
Bonus
1
6000
2000
2300
200
2
2000
300
300
30
3
1000
300
300
40
4
1500
390
490
30
5
8000
900
900
80
6
10000
300
490
89

                                 i.            To display the frequency of employees department wise.
                               ii.            To list the names of those employees whose name starts with ‘H’.
                              iii.            To add a new column in salary table. The column name is Total_Sal.
                             iv.            To store the corresponding values in the Total_Sal coumn.
                               v.            Select max(Basic) from SALARY where Bonus>40;
                             vi.            Select count(*) from EMPLOYEE group by Sex;
                            vii.            Select Distinct Depid from EMPLOYEE;
4.       Given the following tables FLIGHTS and FARES. Write SQL commands for the statements  (i) to (iv) and give output for SQL queries (v) to (vi):
Table:FLIGHTS
FL_NO
STARTING
ENDING
NO_FLIGHTS
NO_STOPS
IC301
Mumbai
Delhi
8
0
IC799
Bangalore
Delhi
2
1
MC101
Indore
Mumbai
3
0
IC302
Delhi
Mumbai
8
0
AM812
Kanpur
Bangalore
3
1
IC899
Mumbai
Kochi
1
4
AM501
Delhi
Trivandrum
1
5
MU499
Mumbai
Madras
3
3
IC701
Delhi
Ahmedabad
4
0
Table: FARES
FL_NO
AIRLINE
FARE
TAXPER
IC701
Indian Airlines
6500
10
MU499
Sahara
9400
5
AM501
Jet Airways
13450
8
IC899
Indian Airlines
8300
4
IC302
Indian Airlines
4300
10
IC799
Indian Airlines
10500
10
MC101
Deccan Airlines
3500
4

                     i.            Display FL_NO and NO_FLIGHTS from “Kanpur” to “Bangalore” from the table FLIGHTS.
                   ii.            Arrange the contents of the table FLIGHTS in the ascending  order of FL_NO.
                  iii.            Display the FL_NO and fare to be paid for the flights from Delhi to Mumbai using the tables FLIGHTSS and FARES, where the fare to be paid=FARE+FARE*TAXPER/10.
                 iv.            Display the minimum fare ”Indian Airlines” is offering from the table FARES.
                   v.            Select FL_NO, NO_FLIGHTS, AIRLINES from FLIGHTS, FARES where STARTING=”Delhi” and FLIGHTS. FL_NO=FARES.FL_NO.
                 vi.            Select count(distinct ENDING) from FLIGHTS.
                vii.            Given the tables stationery and CONSUMER. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)

Table:STATIONERY
S_ID
StationeryName
Company
Price
DP01
Dot pen
ABC
10
PL02
Pencil
XYZ
6
ER05
Eraser
XYZ
7
PL01
Pencil
CAM
5
GP02
Gel pen
AMC
15
Table: CONSUMER
C_ID
ConsumerName
Address
S_ID
01
Good Learner
Delhi
PL01
06
Write Well
Mumbai
GP02
12
Topper
Delhi
DP01
15
Write and Draw
Delhi
PL02
16
Motivation
Bangalore
PL01

                                 i.            To display the details of those Consumers whose Address is Delhi.
                               ii.            To display the details of the stationery whose Price is in the range of 8 to 15 (Including).
                              iii.            To display the ConsumerName, Address from table CONSUMER and Company, Price from table STATIONERY with their corresponding matching S_ID.
                             iv.            To increase Price of all stationery  by 2.
                               v.            Select distinct Address from CONSUMER.
                             vi.            Select CONSUMER, max(Price), min(Price), count(*) from STATIONERY group by Company;
                            vii.            Select CONSUMER.ConsumerName, STATIONERY.StationeryName, STATIONERY.price from STATIONERY, CONSUMER where CONSUMER.S_ID=STATIONERY.S_ID;
                          viii.            Select StationeryName, Price*3 from STATIONERY;