The document discusses C++ programs involving classes and objects. It includes the definition of classes such as Applicant, Housing, Tour, Account and subclasses Current and Savings. The Applicant class stores applicant details and grades, Housing stores housing property data, Tour calculates tour fares, and Account is the base class for banking accounts with subclasses Current and Savings that inherit and expand its functionality. Member functions are defined to input, output and manipulate object data for these classes.
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
Practical Class 12th (c++programs+sql queries and output) Aman Deep
Just download this and do some specific changes in the name section and roll no section . and submit it as it is to your teacher this will surely work and help you out your class 12th board practicals exam . no worries ! ENJOY :) !
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
Practical Class 12th (c++programs+sql queries and output) Aman Deep
Just download this and do some specific changes in the name section and roll no section . and submit it as it is to your teacher this will surely work and help you out your class 12th board practicals exam . no worries ! ENJOY :) !
Computer science Investigatory Project Class 12 C++Rushil Aggarwal
This project is based on File Handling . An innovative project on petrol pump management , deals with basic function in a petrol pump .
Do like , share and comment if my work helped you ;)
Computer science Investigatory Project Class 12 C++Rushil Aggarwal
This project is based on File Handling . An innovative project on petrol pump management , deals with basic function in a petrol pump .
Do like , share and comment if my work helped you ;)
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
1. 1 | P a g e
C++ Tour
1. Write C++ program that uses various functions to sum following
series:
(i) (1) + (1+2) + (1+2+3) + (1+2+3+4) +…………… upto N terms
(ii) (22) + (22+42) +(22+42+62) +(22+42+62+82) up to N terms
(iii) 1 + 1/3+ 1/5+ 1/7 + 1/9+….. Up to N terms.
PROGRAM(i):
#include<iostream.h>
#include<conio.h>
void main()
{
int k=0, m=0;
clrscr();
cout<<"Enterthe limit of the series: ";
cin>>m;
for(inti=1;i<=m;i++)
{
for(intj=1;j<=i;j++)
k+=j;
}
cout<<"Sum of the given series is: "<<k;
getch();
}
Program (ii)
#include<iostream.h>
#include<conio.h>
void main()
{
int k=0, m=0, s=0;
clrscr();
cout<<"Enter the limit of the series: ";
cin>>m;
for(int i=2;i<=m;i=i+2)
{
for(int j=2;j<=i;j=j+2)
{
s=j*j;
k+=s;
}
}
cout<<"Sum of the given series is: "<<k;
getch();
}
Program (iii)
#include<iostream.h>
#include<conio.h>
void main()
{
float k, s=1;
int m=0;
clrscr();
cout<<"Enterthe limit of the series: ";
cin>>m;
for(intj=3;j<=m;j=j+2)
{
k=(float)1/j;s+=k;
}
cout<<endl;
cout<<"Sum of the given series is: "<<s;
getch();
2. 2 | P a g e
}
2. Write a program to record score of a cricket match. One array stores
information of batting team such as bat'sman name, runs scored, indication if
out, mode by which out along with total runs, overs played, total overs and extras.
The other array stores information about bowling team such as bowler's name,
over's bowled, maiden overs, runs given, and wicked taken. The program reads in
the above information and depending upon the user'schoice, it displays either the
batting team's information or the bowling team's information.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct batting
{char batsman[20];
int run, out, tot_run, overs, total_over,extra;
};
struct bowling
{char bowler[20];
int overs, maiden_overs, runs, wicket;
};
void main()
{int b,f;
clrscr();
batting bat_team[12]; bowling bo_team[12];
cout<<"n Enter records of batting team :nn"<<endl;
cout<<"Enterthe no of bat's man:";
cin>>b;
for(inti = 0; i < b ; i++)
{cout<<"n Enter bat's man name :";
gets(bat_team[i].batsman);
cout<<"n Enter run scored :";
cin>>bat_team[i].run;
cout<<"n Type 0 NOT-OUT,Type 1 if OUT:";
cin>>bat_team[i].out;
cout<<"n Enter total run :";
cin>>bat_team[i].tot_run;
cout<<"n Enter no. of overs played :";
cin>>bat_team[i].overs;
cout<<"n Enter total over:";
cin>>bat_team[i].total_over;
cout<<"n Extra ?";
cin>>bat_team[i].extra;
}
cout<<"n Enter records of bowling team :nn"<<endl;
cout<<"enter the no of Bowlers:";
cin>>f;
for(i = 0; i < f ; i++)
{cout<<"n Enter bowler'sname :";
gets(bo_team[i].bowler);
3. 3 | P a g e
cout<<"n Enter overs bowled :";
cin>>bo_team[i].overs;
cout<<"n Enter maiden overs :";
cin>>bo_team[i].maiden_overs;
cout<<"n Enter runs :";
cin>>bo_team[i].runs;
cout<<"n Enter wickedtaken:";
cin>>bo_team[i].wicket;}
char ch;
int n;
do
{clrscr();
cout<<"n Enter 1 to view batting team information:";
cout<<"n Enter 2 to view bowlingteam information:";
cout<<"n Enter your choice:";
cin>>n;
switch(n)
{case 1:
cout<<"n ************* BATTINGTEAM *************n";
cout<<"n Name t RUN-Scored Out Total-run Over's-playedTotal-OversExtra ";
for(i = 0; i < b; i++)
{cout<<"n"<<bat_team[i].batsman <<"t"<<bat_team[i].run<<" ";
if(bat_team[i].out)
cout<<"OUT";
else
cout<<"NOT-OUT";
cout<< " " <<bat_team[i].tot_run<< " " <<bat_team[i].overs << " " <<bat_team[i].total_over
<< " "<<bat_team[i].extra;}
break;
case 2:
cout<< "n ************* BOWLINGTEAM*************n";
cout<< "n Name t Overs_bowledMaiden-Overs Runs-Given Wicket-Taken";
for(i = 0; i < f ; i++)
{cout<<"n"<<bo_team[i].bowler<< "t"<<bo_team[i].overs<< " ";
cout<< " "<<bo_team[i].maiden_overs<< " "<<bo_team[i].runs<< " "<<bo_team[i].wicket<<"";}
break;
default:
cout<< "n Wrong choice.";
}
cout<<"n Do youcontinue (y/n)";cin>>ch; }while(ch=='y'||ch=='Y');
getch();
}
4. 4 | P a g e
Classes and objects
1. Define a class Applicant in C++ with the following description:
Private Members:
1. A data member ANo (Admission Number) of type long ,A data member Name
of type string
2. A data member Agg (Aggregate Marks) of type float ,A data member Grade of
type char
3. A member function GradeMe() to find the Grade as per the Aggregate Marks
obtained by a student. Equivalent Aggregate Marks range and the respective
Grades are shown as follows:
Aggregate Marks
Grade >=80 A
less than 80 and >=65 B
less than 65 ad >=50 C
less than 50 D
Public Members:
1. A function ENTER() to allow user to enter values for Ao, Name, Agg and call
function GradeMe() to find the Grade.
2. A fuctionRESULT() to allow user to view the content of all the data members.
Program:-
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class Applicant
{
long ANO;
char NAME[25], Grade;
float Agg;
void GradeMe()
{
if(Agg>=80)
Grade='A';
else if(Agg>=65 && Agg<80)
Grade='B';
else if(Agg>=50 && Agg<65)
Grade='C';
else if(Agg<50)
Grade='D';
}
public:
void ENTER()
{
5. 5 | P a g e
cout<<"EnterAdmission No:";
cin>>ANO;
cout<<"EnterName of the Applicant :";
gets(NAME);
cout<<"EnterAggregare Marks obtained by the Candidate out of 100:";
cin>>Agg;
GradeMe();
}
void RESULT()
{
cout<<"*******Applicat Details***********"<<endl;
cout<<"Admission No: "<<ANO<<endl;
cout<<"Name of the Applicant: "<<NAME<<endl;
cout<<”Aggregare Marks obtained by the Candidate out of 100:"<<Agg<<endl;
cout<<"Grade Obtained: "<<Grade<<endl; }
};
void main()
{ clrscr();
Applicant a1;
a1.ENTER();
a1.RESULT();
getch();
}
6. 6 | P a g e
2. Write a C++ program to perform various operations on a string class without
using language supported built-in string functions. The operations on a class are:
a) Read a string
b) Display the string
c) Reverse the string
d) Copy the string into an empty string
e) Concatenate two strings
Program:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
class string
{char str1[20];
char str2[20];
public:
void read()
{cout<<"nEnter string :=> ";
cin>>str1; }
void Display()
{cout<<endl<<"The entered string is: "<<str1; }
void reverse();
void copy();
void concatenate();};
void string::reverse()
{inti,l,j=0;
cout<<"nEnter string :=> ";
cin>>str1;
l=strlen(str1);
for(i=l-1;i>=0;i--)
{str2[j]=str1[i];
j++; }
str2[j]='0';
cout<<"Reverse is: "<<str2; }
void string::copy()
{int i;
cout<<"nEnter string :=> ";
cin>>str1;
for(i=0;i<=strlen(str1);i++)
{ str2[i]=str1[i]; }
7. 7 | P a g e
str2[i]='0';
cout<<"Copy is: "<<str2; }
void string::concatenate()
{inti,l;
cout<<"nEnter string1 :=> ";
cin>>str1;
cout<<"nEnter string2 :=> ";
cin>>str2;
l=strlen(str1);
for(i=0;i<=l;i++)
{str1[l+i]=str2[i]; }
cout<<"Copy is: "<<str1; }
void main()
{ clrscr();
int choice; string s1;
l1:
cout<<"n1.Read the string"<<endl;
cout<<"2.Display the string "<<endl;
cout<<"3.Reverse the string"<<endl;
cout<<"4.Copy the string"<<endl;
cout<<"5.Concatenate two strings"<<endl;
cout<<"6.Exit"<<endl;
cout<<"Enteryour choice:";
cin>>choice;
switch(choice)
{case 1:
s1.read();
goto l1;
break;
case 2:
s1.Display();
goto l1;
break;
case 3:
s1.reverse();
goto l1;
break;
case 4:
s1.copy();
goto l1;
break;
case 5:
s1.concatenate();
goto l1;
break;
case 6:
exit(0);
break;
}
getch();
8. 8 | P a g e
}
3. Define a class named HOUSING in C++ with the following description:
Private Members:
REG_NO integer (Ranges 10 - 2000)
NAME Array of characters (String)
TYPE Character
COST Float
Public Members:
1. Function Read_Data() to read an object of HOUSING type. Function Display() to
display the details of an object.
2. Function Draw-Nos() to choose and display the details of 2 houses selected
randomly from an array of 10 objects of type HOUSING. Use randomfunction to
generate the registration nos. to match with REG_NO from the array.
Program:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
classHOUSING
{private:
intREG_NO;
char NAME[50];
char TYPE[20];
floatCOST;
public:
voidRead_Data();
voidDisplay();
voidDraw_Nos();
};
voidHOUSING::Read_Data()
{cout<<"Enter RegNo(10 - 1000): ";
cin>>REG_NO;
cout<<"Name:";
gets(NAME);
cout<<"Type:";
gets(TYPE);
cout<<"Cost: ";
cin>>COST;
}
voidHOUSING::Display()
{cout<<"RegNo:"<<REG_NO<<endl;
cout<<"Name:"<<NAME<<endl;
cout<<"Type:"<<TYPE<<endl;
cout<<"Cost: "<<COST<<endl;
}
voidHOUSING::Draw_Nos()
{intArr[5];
intno1,no2,i;
randomize();
no1=random(991)+10;
cout<<"Randomno-
1:"<<no1<<endl<<"Randomno-
2:"<<no2<<endl;
for(i=0;i<100;i++)
{
if((Arr[i]==no1)||(Arr[i]==no2))
Display();
} }
voidmain()
{ clrscr();
HOUSING a1;
a1.Read_Data();
a1.Display();
a1.Draw_Nos();
getch();
}
9. 9 | P a g e
Constructor and destructor
1. Define a class Tour C++ with the description given below:
Private Members:
TCodeof type string
NoofAdults of type integer
NoofKids of type integer
Kilometres of type integer
TotalFare of type float
Public Members:
1. A constructor to assign initial values as follows:
TCode with the word "NULL"
NoofAdults as 0
NoofKids as 0
Kilometres as 0
TotalFare as 0
2. A function AssignFare() which calculates and assign the value of the date
member TotalFare as follows:
For each Adult
Fare(Rs) ForKilometres
500 >=1000
300 <1000 &>=500
200 <500
For each Kid the above Fare will be 50% of the Fare mentioned in the above table.
For example:
If Distance is 850, NoofAdults=2 and NoofKids =3 ,ThenTotalFare should be
calculated as NoofAdults*30 + NoofKids *150 i.e., 2*300+3*150=1050
3. A function EnterTour() to input the values of the data members TCode,
Noofadults, NoofKids and Kilometres; and invoke the AssignFare() function
4. A Function ShowTour() which display the content of all the data members
for a Tour.
Program:-
#include<iostream.h>
#include<conio.h>
#include<string.h>
class Tour
{
char TCode[5];
int NoofAdults,NoofKids, Kilometeres,TotalFare;
public:
Tour ()
{
11. 11 | P a g e
Inheritance
1. Assume that a bank maintains two kinds of accounts for customers, one called as
savings account and the other as current account. The saving account provides
compound interest and withdrawal facilities but not cheque book facility. The
current account provides cheque book facility but no interest. Current account
holders should also maintains a minimum balance and if the balance falls below
this level, a service charge is imposed.
Create a class Account that stores customer name, account number and opening
balance.
From this derive the classes Current and saving to make them more specific to
their requirements. Include necessary member functions in order to achieve the
following tasks:
(i) Deposit an amount for a customer and update the balance
(ii) Display the account details
(iii) Compute and deposit interest
(iv)Withdraw amount for a customer after checking the balance and update the
balance.
(v) Check for the minimum balance (for current account holders), impose penalty,
if necessary, and update the balance.
Implement these without using any constructor.
Program:-
#include<process.h>
#include<iostream.h>
#include<conio.h>
#include<math.h>
int const min_bal=500;
class account
{
int ac_no;
char cu_name[20];
protected:
int o_bal;
public:
void in();
void out();
};
void account::in()
{
cout<<"Enterthe accountnumber of Customer:";
cin>>ac_no;
cout<<"Enterthe name of Customer:";
cin>>cu_name;
cout<<"Enterthe Opening Balance:";
cin>>o_bal;
}
void account::out()
{
cout<<"===============================Customer
Info========================"<<endl;
12. 12 | P a g e
cout<<"Accountno of Customer:"<<ac_no<<endl;
cout<<"Customer Name:"<<cu_name<<endl;
cout<<"Current Opening Balance:"<<o_bal<<endl;
}
class current:public account
{
float dep,wit;
public:
void depo();
void with();
void pena();
}c;
void current::pena()
{
if(o_bal<min_bal)
{
o_bal=o_bal-150;
}
cout<<"YourTotal Amount after Penalty:"<<o_bal<<endl;
}
void current::depo()
{
if(o_bal>min_bal)
{
cout<<"Enteryour deposit Amount:";
cin>>dep;
o_bal+=dep;
account::out();
cout<<"YourTotal Amount after Deposit:"<<o_bal<<endl;
}
else
{
cout<<"YourBalance is not sufficientto open Account:"<<endl;
}
}
void current::with()
{
if(o_bal>min_bal)
{
cout<<"EnterYour amount to Withdraw:";
cin>>wit;
if(wit<o_bal-min_bal)
{
o_bal-=wit;
account::out();
cout<<"YourTotal Amount after withdraw is:"<<o_bal<<endl;
if(o_bal<min_bal)
{
pena();
}
}
else
{
account::out();
cout<<"Withdraw not Possible:"<<endl;
}
}
13. 13 | P a g e
else
{
account::out();
cout<<"YourBalance is not sufficientto open account:"<<endl;
pena();
}
}
class savings:public account
{
float dep,wit,c_int,r,t;
public:
void depo()
{
cout<<"Enteryour deposit Amount:";
cin>>dep;
o_bal+=dep;
account::out();
cout<<"YourTotal Amount after deposit is:"<<o_bal<<endl;
}
void with()
{
cout<<"EnterYour amount to Withdraw:";
cin>>wit;
if(wit<o_bal-min_bal)
{
o_bal-=wit;
account::out();
cout<<"YourTotal Amount after withdraw is:"<<o_bal<<endl;
}
else
{
account::out();
cout<<"Withdraw not Possible:"<<endl;
}
}
void c_in()
{
cout<<o_bal<<endl;
cout<<"Enteryour rate:";
cin>>r;
cout<<"Enteryour time:";
cin>>t;
c_int=o_bal*pow(1+r/100,t)-o_bal;
o_bal+=c_int;
account::out();
cout<<"YourCompound interest is:"<<c_int<<endl;
cout<<"The Main Balance is:"<<o_bal<<endl;
}
}s;
void main()
{
int n,cu,sa;
char ch;
do
{
clrscr();
cout<<"1.CURRENT:"<<endl;
14. 14 | P a g e
cout<<"2.SAVINGS:"<<endl;
cout<<"3.Exit:"<<endl;
cout<<"Enteryour choice:";
cin>>n;
switch(n)
{
clrscr();
case 1:
c.in();
cout<<"1.Deposit:"<<endl;
cout<<"2.Withdraw:"<<endl;
cout<<"3.Exit:"<<endl;
cout<<"Enteryour choice:";
cin>>cu;
switch(cu)
{
case 1:
c.depo();
break;
case 2:
c.with();
break;
case 3:
exit(0);
break;
}
break;
case 2:
clrscr();
s.in();
cout<<"1.Deposit:"<<endl;
cout<<"2.Withdraw:"<<endl;
cout<<"3.Compound interest:"<<endl;
cout<<"4.Exit:"<<endl;
cout<<"Enteryour choice:";
cin>>sa;
switch(sa)
{
case 1:
s.depo();
break;
case 2:
s.with();
break;
case 3:
s.c_in();
break;
case 4:
exit(0);
break;
}
break;
case 3:
exit(0);
break;
}
cout<<"EnterY or y to continue:";
15. 15 | P a g e
cin>>ch;
}
while(ch=='Y' ||ch=='y');
getch();
}
2. Write a declaration for a class Person which has the following:
1. data members name, phone
2. set and get functions for every data member
3. a display function
4. a destructor
(i) For the Person class above, write each of the constructor, the assignment
operator, and the getName member function. Use member initialization lists as
often as possible.
(ii) Given the Person class above, write the declaration for a class Spouse that
inherits from Person and does the following:
1. has an extra data member spouseName
2. redefines the display member function.
(iii) For the Spouse class above, write each of the constructors and the display
member function. Use member initialization lists as often as possible.
Program:-
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
classPerson
{
public:
longphone;
char name[20];
voidset()
{ strcpy(name,"NULL");
phone=7878963522;
}
voidget()
{ cout<<"Enter name:";
gets(name);
cout<<"Enter phone:";
cin>>phone;
}
voiddisplay()
16. 16 | P a g e
{ cout<<"Name:"<<name<<endl;
cout<<"Phone:"<<phone<<endl;
}
Person()
{ strcpy(name,"Rahul");
phone=9965869922;
}
Person(charna[20],longph)
{ name[20]=na[20];
phone=ph;}
voidgetName()
{ cout<<"Enter name:";
gets(name);
}
};
classSpouse:publicPerson
{
char spouseName[20];
public:
voidgetName()
{
cout<<"Enter name:";
gets(spouseName);
}
voiddisplay()
{cout<<"Name:"<<spouseName<<endl;
cout<<"Phone:"<<phone<<endl;
cout<<"spouse name:"<<spouseName<<endl;
}
Spouse()
{strcpy(spouseName,"NULL");
}};
voidmain()
{
clrscr();
Personp;
Spouse s;
p.set();
p.get();
p.display();
s.getName();
s.display();
getch();
};
3. Create the following class hierarchy in C++.
17. 17 | P a g e
Data file handling
1. Write a program to read text file “Article.txt” and do the following
a) Find to & the.
b) Count vowels.
c) Count number of words.
d) Count Upper letters.
e) Count Digit & Special character.
Program:-
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<fstream.h>
#include<ctype.h>
#include<string.h>
classDFH
{
public:
voidopen()
{
ofstreamfi;
fi.open("Article.txt");
fi<<"See the magicof C++"<<endl;
fi.close();
}
voidTt()
{
open();
18. 18 | P a g e
char n[80];
inta=0,d=0;
clrscr();
ifstreamf("Article.txt");
while(!f.eof())
{
f>>n;
for(inti=0;n[i]!=NULL;i++)
{
n[i]=tolower(n[i]);
}
if(strcmp(n,"to")==0)
a++;
else if(strcmp(n,"the")==0)
d++;
}
cout<<"Occurence of to in file is{"<<a<<"}Times"<<endl;
cout<<"Occurence of the infile is{"<<d<<"}Times"<<endl;
getch();
}
voidCv()
{
open();
char c;
intv=0;
clrscr();
ifstreamf("Article.txt");
while(!f.eof())
{
f.get(c);
if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U')
{
v++;
}
}
cout<<"Total numbersvowels="<<v<<endl;
}
voidNow()
{
open();
char word[80];
intcount=0;
clrscr();
ifstreamf("Article.txt");
while(!f.eof())
{
f>>word;
count++;
}
cout<<"Numberof wordsinthe file:"<<count-1<<endl;
}
voidUp()
{
open();
char c[80];
19. 19 | P a g e
intl=0;
clrscr();
ifstreamf("Article.txt");
while(!f.eof())
{
f>>c;
for(inti=0;c[i]!=NULL;i++)
{
if(isupper(c[i]))
{
l++;
}
}
}
cout<<"Total numbersof Upperletters="<<l<<endl;
}
voidDsc()
{
open();
char j[80];
intn=0;
clrscr();
ifstreamf("Article.txt");
while(!f.eof())
{
f>>j;
for(inti=0;j[i]!=NULL;i++)
{
if(isdigit(j[i]))
{
n++;
}
}
}
cout<<"Total numbersof digits="<<n<<endl;
}
}N;
voidmain()
{
intn;
char ch;
do
{
clrscr();
cout<<"1.Findto & the"<<endl;
cout<<"2.CountVowels"<<endl;
cout<<"3.Countno of words"<<endl;
cout<<"4.CountUpper letters"<<endl;
cout<<"5.Digit& special character"<<endl;
cout<<"6.Exit"<<endl;
cout<<"Enter yourchoice fromabove:";
cin>>n;
switch(n)
{
case 1:
20. 20 | P a g e
N.Tt();
break;
case 2:
N.Cv();
break;
case 3:
N.Now();
break;
case 4:
N.Up();
break;
case 5:
N.Dsc();
break;
case 6:
exit(0);
break;
default:
cout<<"Wrong Choice..........!!!!!!!!!!!!!"<<endl;
}
cout<<"Enter Y or y to continue:";
cin>>ch;
}while(ch=='Y'|| ch=='y');
getch();
}
Array
Program 1:
Write a functionin C++ to print the product ofeach column of a two dimensional integerarray
passedas the argument of the function.
Explain:If the two dimensional array contains
Then the output shouldappear:
Product of Column1=24
Product of Column2=30
Product of Column3=240
#include<iostream.h>
#include<conio.h>
voidColProd(intA[4][3],intr,intc)
1 2 4
3 5 6
4 3 2
2 1 5
21. 21 | P a g e
{ intProd[50],i,j;
for(j=0;j<c;j++)
{ Prod[j]=1;
for(i=0;i<r;i++)
Prod[j]*=A[i][j];
cout<<"Productof Column"<<j+1<<"="<<Prod[j]<<endl;}
}
voidmain()
{
intArr[4][3]={{1,2,4},{3,5,6},{4,3,2},{2,1,5}};
clrscr();
ColProd(Arr,4,3);
getch();
}
Program 2:
Write a function in C++ which accepts a 2D array of integers and its size as
arguments and display the elements which lie on diagonals.
[Assuming the 2D Array to be a square matrix with odd dimension i.e., 3 x 3, 5 x 5,
7 x 7 etc….] Example, if the array content is
5 4 3 6 7 8 1 2 9
Output through the function should be: Diagonal One: 5 7 9
Diagonal Two: 3 7 1
#include<iostream.h>
#include<conio.h>
#define max 100
void diagnol(int a[max][max],int n=3,int m=3)
{
int i,j;
cout<<"nn";
cout<<"diagonal 1";
cout<<"nn";
22. 22 | P a g e
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{if(i==j) { cout<<a[i][j]<<"t"; }
}}
cout<<"nn";
cout<<"diagonal 2";
cout<<"nn";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{if(i+j==m-1)
{
cout<<a[i][j]<<"t";
}
}
}
}
void main()
{
clrscr();
int a[max][max],i,j,m,n;
cout<<"enter the no. of row:";
cin>>n;
cout<<"enter the no. of column:";
cin>>m;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout<<"enter elements a["<<i+1<<"]["<<j+1<<"];";
// cout<<"n";
cin>>a[i][j];
}
}
diagnol(a,n,m);
getch();
}
Program 3:
Insert or Delete an element in array.
#include<iostream.h>
#include<conio.h>
#include<process.h>
classID
{
public:
voidInsert()
{
inta[60],n,item,pos;
clrscr();
cout<<"Enter the no.of Elements:";
cin>>n;
for(inti=0;i<n;i++)
23. 23 | P a g e
{
cout<<"Element["<<i+1<<"]:";
cin>>a[i];
}
cout<<"Enter the itemtobe inserted:";
cin>>item;
cout<<"Enter the position:";
cin>>pos;
for(i=n;i>=pos;i--)
{
a[i+1]=a[i];
}
a[pos]=item;
n=n+1;
cout<<"The modifiedarrayis:"<<endl;
for(i=0;i<n;i++)
{
cout<<"Element["<<i+1<<"]:"<<a[i]<<endl;
}
getch();
}
voidDelete()
{
clrscr();
inta[50],x,n,i,j,b[50];
cout<<"Enter the no of Elements:";
cin>>n;
for(i=0;i<n;++i)
{
cout<<"Element["<<i+1<<"]:";
cin>>a[i];
}
cout<<"Enter elementtodelete:";
cin>>x;
for(i=0,j=0;i<n;++i)
{
if(a[i]!=x)
{
b[j++]=a[i];
}
}
if(j==n)
{
cout<<"Soory!!!Elementisnotinthe Array";
exit(0);
}
else
{
cout<<"NewArrayis ";
for(i=0;i<j;i++)
{
cout<<"Element["<<"]:"<<b[i]<<endl;
}
}
24. 24 | P a g e
getch();
}
}f;
voidmain()
{
intn;
char ch;
do
{
clrscr();
cout<<"1.Insert"<<endl;
cout<<"2.Delete"<<endl;
cout<<"3.Exit"<<endl;
cout<<"Enter the numberfromabove:";
cin>>n ;
switch(n)
{
case 1:
f.Insert();
break;
case 2:
f.Delete();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Choice!!!!!!!!!!!!!!!!!!"<<endl;
}
cout<<"Enter Y or y to continue";
cin>>ch;
}while(ch=='y'||ch=='Y');
getch();
}
Program 4:
Stack
#include<iostream.h>
#include<conio.h>
#include<process.h>
#define max 5
inttop=-1;
classstack
{
int x,s[max],si;
public:
26. 26 | P a g e
s1.push();
break;
case 2:
s1.pop();
break;
case 3:
s1.peep();
break;
case 4:
s1.display();
break;
case 5:
exit(0);
break;
default:
cout<<"Invalidchoice:"<<endl;
}
cout<<"Enter Y to continue:";
cin>>ch;
}
while(ch=='Y'||ch=='y');
getch();
}
Program 3:
Queue
#include<iostream.h>
#include<conio.h>
#include<process.h>
classqueue
28. 28 | P a g e
cout<<"3.Display"<<endl;
cout<<"4.Exit"<<endl;
do
{
cout<<"Enter Your choice:";
cin>>n;
switch(n)
{
case 1:
q.insert();
break;
case 2:
q.Delete();
break;
case 3:
q.display();
break;
case 4:
exit(0);
break;
default:
cout<<"Invalidoption...."<<endl;
}
cout<<"Enetr y to Continue:";
cin>>ch;
}
while(ch=='Y'||ch=='y');
getch();
}
Program 4:
36. 36 | P a g e
voidmain()
{
mergesortobj;
intn;
char ch;
do
{
clrscr();
cout<<"1.Merge sort:"<<endl;
cout<<"2.Selectionsort:"<<endl;
cout<<"3.Bubble Sort:"<<endl;
cout<<"4.Exit:"<<endl;
cout<<"Enter Your Choice:";
cin>>n;
switch(n)
{
case 1:
clrscr();
obj.getdata();
obj.sortLogic();
obj.showdata(1);
obj.showdata(2);
obj.showdata(3);
break;
case 2:
clrscr();
Selectsort();
break;
case 3:
clrscr();
Bubblesort();
break;
case 4:
exit(0);
break;
default:
cout<<"Invalidoption....."<<endl;
}
cout<<"Enter Y to continue:";
cin>>ch;
}
while(ch=='Y'||ch=='y');
getch();
}
37. 37 | P a g e
My SQL Query
1. Display the dept information from department table
Ans: select * from dept;
2. Display the name and job for all employees
Ans: select ENAME, JOB from emp;
3. Display the names of all employees who are working in department number 10
Ans: select * from emp where DEPTNO like ‘10%’;
4. Display the names of employees working in department number 10 or 20 or 40
or employees working as clerks,
salesman or analyst
Ans: select ENAME from emp where deptno in (10, 20, 40) and job in
(‘clerk’,’salesman,’analyst,’);
5. Display the names of employees in descending order of salary
Ans: select ENAME from emp order by sal desc;
6. Display name, salary, Hra, pf, da, TotalSalary for each employee.
Ans: select ENAME, sal*0.15”HRA”, (sal*0.10)”DA”, (sal*0.05)”PF”,
((sal+sal*015+sal*0.10))-sal*0.50)”Total salary” from emp;
38. 38 | P a g e
7. Display department numbers and Maximum Salary from each Department?
Ans: select max (sal), deptno from emp group by deptno;
8. Display the department Number with more than three employees in each
department?
Ans: select deptno, count (EMPNO) from emp group by deptno having count (empno)>3;
9. Display various jobs along with total salary for each of the job where total salary
is greater than 40000?
Ans: select job, sum (sal) from emp group by job having sum (sal)>40000;
10. Display the various jobs along with total number of employees in each job.The
Output should contain only those jobs with more than three employees?
Ans: select job, count (ENAME) from emp groupby job having count (ENAME)>3;
11.To insert a new row in the ARRIVALS table with the following data;
14,”Velvet Touch”,”Double Bed”.{25/03/03},25000,30
Ans.insert into ARRIVALS values
(14,”Velvet Touch”,”Double Bed”.{25/03/03},25000,30);
12.To display the BOOK_ID,BOOK_NAME and Quantity_issued for all the books
which have been issued.
Ans.select BOOK.BOOK_ID,BOOK_NAME,QUANTITY_ISSUED
From BOOKS,ISSUED
Where BOOK.BOOKS_ID=ISSUED.BOOK_ID;
13.To display minimum rate of items for each Supplier individually as per Scode
from the table store.
Ans.select Scode,Min(rate)
From store group by Scode;
14.To increase the price of all products by 10.
Ans.update PRODUCT
SET price=Price+10;
39. 39 | P a g e
15.To add a new column name “MARKS”
Ans.Alter table student
Add marks float(6,2);