SlideShare une entreprise Scribd logo
1  sur  52
COMPUTER SCIENCE
Practical File
On
C++ PROGRAMS
&
MY SQL
ROLL NO . :-
Class –
Submitted By :-
C++ PROGRAMS
INDEX
Q1.Enter name , age and salary and display it by using outside
the class member .
Q2. Program which gives the squares of all the odd numbers
stored in an array .
Q3.Program to store numbers in an array and allow user to
enter any number which he/she wants to find in array .(Binary
Search)
Q4.Program for copy constructor .
Q5.Enter numbers in an array in any order and it will give the
output of numbers in ascending order .
Q6. Enter any number from 2 digit to 5 digit and the output
will be the sum of all the distinguish digits of the numbers .
Q7.Enter rows and columns and the output will be the sum of
the diagonals .
Q8. Enter item no. , price and quantity in a class .
Q9.Enter any line or character in a file and press * to exit the
program .
Q10. Program will read the words which starts from vowels
stored in a file .
Q11. Enter employee no , name , age , salary and store it in a
file.
Q12. Deleting the information of employee by entering the
employee number .
Q13. Enter any number and its power and the output will the
power of the number .
Q14. Enter 3 strings and the output will show the longest
string and the shortest string .
Q.15 Enter any number and the output will be all the prime
numbers up to that number .
Q16. Selection sort
Q17. Using loop concept the program will give the output of
numbers making a right triangle .
Q18. Program for Stacks and Queue .
Q.19Enter two arrays and the output will be the merge of two
arrays .
Q20. Sequence sort .
Q.SQL QUERIES AND OUTPUT .
Q1.Enter name , age and salary and display it by using outside
the class member .
#include<iostream.h>
#include<conio.h>
class abc
{
//private:
char n[20];
int a;
float sal;
public:
void getdata(void)
{
cout<<"nEnter name ";
cin>>n;
cout<<"nEnter age ";
cin>>a;
cout<<"nEnter salary ";
cin>>sal;
}
void putdata(void)
{
cout<<"nnNAME IS "<<n;
cout<<"nAGE IS "<<a;
cout<<"nSALARY IS "<<sal;
}
};
main()
{
abc p;
clrscr();
p.getdata();
p.putdata();
getch();
}
OUTPUT
Q2. Program which gives the squares of all the odd numbers
stored in an array .
#include<iostream.h>
#include<conio.h>
main()
{
int a[20],i,x;
clrscr();
cout<<"nEnter no of elements ";
cin>>x;
for(i=0;i<x;i++)
{
cout<<"nEnter no ";
cin>>a[i];
}
cout<<"nnArr1: ";
for(i=0;i<x;i++)
cout<<" "<<a[i];
cout<<"nnArr1: ";
for(i=0;i<x;i++)
{
if(a[i]%2==1)
a[i]=a[i]*a[i];
cout<<" "<<a[i];
}
getch();
}
OUTPUT
Q3.Program to store numbers in an array and allow user to
enter any number which he/she wants to find in array .(Binary
Search)
#include<iostream.h>
#include<conio.h>
main()
{
int a[20],n,i,no,low=0,high,mid,f=0;
clrscr();
cout<<"nEnter no of elements ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"nEnter no ";
cin>>a[i];
}
cout<<"nn";
for(i=0;i<n;i++)
cout<<" "<<a[i];
cout<<"nEnter no to be search ";
cin>>no;
high=n-1;
while(low<=high && f==0)
{
mid=(low+high)/2;
if(a[mid]==no)
{
cout<<"nn"<<no<<" store at "<<mid+1;
f=1;
break;
}
else if(no>a[mid])
low=mid+1;
else
high=mid-1;
}
if(f==0)
cout<<"nn"<<no<<" does not exist";
getch();
}
OUTPUT
Q4.Program for copy constructor .
#include<iostream.h>
#include<conio.h>
#include<string.h>
class data
{
char n[20];
int age;
float sal;
public:
data(){}
data(char x[],int a,float k)
{
strcpy(n,x);
age=a;
sal=k;
}
data(data &p)
{
strcpy(n,p.n);
age=p.age;//+20;
sal=p.sal;//+1000;
}
display()
{
cout<<"nnNAME : "<<n;
cout<<"nnAGE : "<<age;
cout<<"nnSalary: "<<sal;
}
};
main()
{
clrscr();
data d("ajay",44,5000); //implicit caling
data d1(d);
data d2=d;
data d3;
d3=d2;
d.display();
d1.display();
d2.display();
d3.display();
getch();
}
OUTPUT
Q5.Enter numbers in an array in any order and it will give the
output of numbers in ascending order .(Bubble Sort)
#include<iostream.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,t;
clrscr();
cout<<"nEnter no of elements in A ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"nEnter no ";
cin>>a[i];
}
cout<<"nn";
for(i=0;i<n;i++)
cout<<" "<<a[i];
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
cout<<"nn";
for(i=0;i<n;i++)
cout<<" "<<a[i];
getch();
}
OUTPUT
Q6. Enter any number from 2 digit to 5 digit and the output
will be the sum of all the distinguish digits of the numbers .
#include<iostream.h>
#include<conio.h>
main()
{
int a=0,b=0,c;
clrscr();
cout<<"nEnter value for A ";
cin>>a;
while(a>0) // for(;a>0;) or for(i=a;i>0;i=i/10)
{
c=a%10;
b=b+c;
a=a/10;
}
cout<<"nSum of digits "<<b;
getch();
}
OUTPUT
Q7.Enter rows and columns and the output will be the sum of
the diagonals .
#include<iostream.h>
#include<conio.h>
main()
{
int a[10][10],i,j,r,c;
clrscr();
cout<<"nEnter no of rows ";
cin>>r;
cout<<"nEnter no of Col ";
cin>>c;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
{
cout<<"nEnter no ";
cin>>a[i][j];
}
int sum=0,sum1=0;
for(i=0;i<r;i++)
{
cout<<"n";
for(j=0;j<c;j++)
{
cout<<" "<<a[i][j];
/// if(i==j) //&& a[i][j]>0)
// cout<<a[i][j];
// else
// cout<<" ";
//sum=sum+a[i][j];
/* if(i+j==r-1)// && a[i][j]>0)
cout<<a[i][j];
else
cout<<" "; */
if(i==j)
sum1=sum1+a[i][j];
}
}
for(i=0;i<r;i++)
{
cout<<"n";
for(j=0;j<c;j++)
{
// cout<<" "<<a[i][j];
/* if(i==j) //&& a[i][j]>0)
cout<<a[i][j];
else
cout<<" ";*/
//sum=sum+a[i][j];
if(i+j==r-1)// && a[i][j]>0)
// cout<<a[i][j];
// else
// cout<<" ";
sum=sum+a[i][j];
}
}
cout<<"nnFirst diagonal sum "<<sum1;
cout<<"nnSecond diagonal sum "<<sum;
getch();
}
OUTPUT
Q8. Enter item no. , price and quantity in a class .
#include<iostream.h>
#include<conio.h>
class dd
{
char item[20];
int pr,qty;
public:
void getdata();
void putdata();
};
void dd::getdata()
{
cout<<"nEnter item name ";
cin>>item;
cout<<"nEnter price ";
cin>>pr;
cout<<"nEnter quantity ";
cin>>qty;
}
void dd::putdata()
{
cout<<"nnItem name:"<<item;
cout<<"nnPrice: "<<pr;
cout<<"nnQty:"<<qty;
}
main()
{
dd a1,o1,k1;
clrscr();
a1.getdata();
o1.getdata();
k1.getdata();
a1.putdata();
o1.putdata();
k1.putdata();
getch();
}
OUTPUT
Q9.Enter any line or character in a file and press * to exit the
program .
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
main()
{
char ch;
clrscr();
ofstream f1("emp"); //implicit
//ofstream f1;
//f1.open("emp",ios::out); //explicit
cout<<"nEnter char ";
while(1) //infinity
{
ch=getche(); // to input a single charactor by keybord.
if(ch=='*')
break;
if(ch==13)
{
cout<<"n";
f1<<'n';
}
f1<<ch;
}
f1.close();
//getch();
}
OUTPUT
Q10. Program will read the words which starts from vowels
stored in a file .
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
main()
{
char ch[80];
int cnt=0;
clrscr();
ifstream f1("emp");
ofstream f2("temp");
while(!f1.eof())
{
f1>>ch;
cout<<ch<<"n";
if(ch[0]=='a' || ch[0]=='e' || ch[0]=='o' || ch[0]=='i' || ch[0]=='u')
f2<<"n"<<ch;
}
f1.close();
f2.close();
cout<<"nnName start with vowels nn";
f1.open("temp",ios::in);
while(f1) //while(!f1.eof())
{
f1>>ch;
cout<<"n"<<ch;
if(f1.eof())
break;
}
f1.close();
getch();
}
OUTPUT
Q11. Enter employee no , name , age , salary and store it in a
file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
int row=5,col=2;
class abc
{
private:
int empno;
char n[20];
int age;
float sal;
public:
void getdata()
{
char ch;
cin.get(ch); // To empty buffer
cout<<"nEnter employee no ";
cin>>empno;
cout<<"nEnter name ";
cin>>n;
cout<<"nEnter age ";
cin>>age;
cout<<"nEnter salary ";
cin>>sal;
}
void putdata()
{
// gotoxy(col,row);
cout<<"n"<<empno;
// gotoxy(col+10,row);
cout<<"t"<<n;
// gotoxy(col+25,row);
cout<<"t"<<age;
// gotoxy(col+35,row);
cout<<"t"<<sal;
// row++;
}
};
main()
{
clrscr();
abc p,p1;
fstream f1("emp5.txt",ios::in|ios::out|ios::binary);
int i;
for(i=0;i<3;i++)
{
p.getdata();
f1.write((char *)&p,sizeof(p));
}
cout<<"nnEMPNOtNAMEtAGEtSALARYn";
f1.seekg(0);
//f1.clear();
//clrscr();
for(i=0;i<3;i++)
{
f1.read((char*)&p1,sizeof(p1));
p1.putdata();
}
f1.close();
getch();
}
OUTPUT
Q12. Deleting the information of employee by entering the
employee number .
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
class abc
{
private:
int empno;
char n[20];
int age;
float sal;
public:
void getdata()
{
cout<<"nEnter employee no ";
cin>>empno;
cout<<"nEnter name ";
cin>>n;
cout<<"nEnter age ";
cin>>age;
cout<<"nEnter salary ";
cin>>sal;
}
void putdata()
{
cout<<"nn"<<empno<<"t"<<n<<"t"<<age<<"t"<<sal;
}
int get_empno()
{
return empno;
}
};
main()
{
abc p,p1;
clrscr();
ifstream f1("emp5.txt",ios::in|ios::binary);
ofstream f2("temp",ios::out|ios::binary);
int i,emp;
cout<<"nnNAMEtAGEtSALARY";
f1.clear();
f1.seekg(0);
//for(i=0;i<4;i++)
while(!f1.eof())
{
f1.read((char*)&p1,sizeof(p1));
if(f1.eof())
break;
p1.putdata();
}
cout<<"nEnter employee no ";
cin>>emp;
f1.clear();
f1.seekg(0);
//while(f1)
while(!f1.eof())
{
f1.read((char*)&p1,sizeof(p1));
if(f1.eof())
break;
if(emp!=p1.get_empno())
f2.write((char*)&p1,sizeof(p1));
}
f1.close();
f2.close();
remove("emp5.txt");
rename("temp","emp5.txt");
f1.open("emp5.txt",ios::in|ios::binary);
cout<<"nnNAMEtAGEtSALARY";
f1.seekg(0);
//for(i=0;i<3;i++)
while(!f1.eof())
{
f1.read((char*)&p1,sizeof(p1));
if(f1.eof())
break;
p1.putdata();
}
f1.close();
getch();
}
OUTPUT
Q13. Enter any number and its power and the output will the
power of the number .
#include<iostream.h>
#include<conio.h>
#include<math.h>
#define CUBE(a,b) pow(a,b)
//a>b?a:b
main()
{
int x,y,z;
clrscr();
cout<<"nEnter base value ";
cin>>x;
cout<<"nEnter power ";
cin>>y;
z=CUBE(x,y);
cout<<"n"<<z;
getch();
}
OUTPUT
Q14. Enter 3 strings and the output will show the longest
string and the shortest string .
#include<iostream.h>
#include<conio.h>
#include<string.h>
main()
{
char n[20],n1[20],n2[20];
int l1,l2,l3;
clrscr();
cout<<"nEnter String1 ";
cin>>n;
cout<<"nEnter String2 ";
cin>>n1;
cout<<"nEnter String3 ";
cin>>n2;
l1=strlen(n);
l2=strlen(n1);
l3=strlen(n2);
(l1>l2 && l1>l3) ?cout<<"nLong: "<<n:(l2>l1 && l2>l3) ? cout<<"nLong: "<<n1
:cout<<"nLong: "<<n2;
(l1<l2 && l1<l3)?cout<<"nshort:"<<n:(l2<l1 && l2<l3)?
cout<<"nshort:"<<n1:cout<<"nshort:"<<n2;
getch();
}
OUTPUT
Q.15 Enter any number and the output will be all the prime
numbers up to that number .
#include<iostream.h>
#include<conio.h>
main()
{
int n,i,j,p;
clrscr();
cout<<"nEnter no of N ";
cin>>n;
for(i=1;i<=n;i++)
{
p=0;
for(j=2;j<=i/2;j++)
if(i%j==0)
p=1;
if(p==0)
cout<<" "<<i;
}
getch();
}
OUTPUT
Q16. Selection sort
#include<iostream.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,t,min,p;
clrscr();
cout<<"nEnter no of elements in A ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"nEnter no ";
cin>>a[i];
}
cout<<"nn";
for(i=0;i<n;i++)
cout<<" "<<a[i];
for(i=0;i<n;i++)
{
min=a[i];
p=i;
for(j=i;j<n;j++)
{
if(a[j]<min)
{
min=a[j];
p=j;
}
}
t=a[i];
a[i]=a[p];
a[p]=t;
}
cout<<"nn";
for(i=0;i<n;i++)
cout<<" "<<a[i];
getch();
}
OUTPUT
Q17. Using loop concept the program will give the output of
numbers making a right triangle .
#include<iostream.h>
#include<conio.h>
main()
{
int i,j;
clrscr();
for(i=1;i<=4;i++)
{
cout<<"nn";
for(j=1;j<=i;j++)
cout<<" "<<i;
}
getch();
}
OUTPUT
Q18. Program for Stacks and Queue .
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
struct queue
{
int x;
queue *next;
}*front=NULL,*rear;
void insert(int);
void delnode();
void display();
void main()
{
int a,ch;
clrscr();
do
{
cout<<"nEnter 1 for Insert";
cout<<"nEnter 2 for Delete";
cout<<"nEnter 3 for display";
cout<<"nEnter 4 for exit";
cout<<"nnEnter your choice ";
cin>>ch;
switch(ch)
{
case 1: cout<<"nEnter no for insert ";
cin>>a;
insert(a);
break;
case 2: delnode();
break;
case 3: display();
break;
case 4: exit(0);
}
}
while(1);
getch();
}
void insert(int no) // char str[]
{
queue *ptr;
ptr=new queue; // strcpy(ptr->n,str)
// ptr=(struct queue*)malloc(sizeof(struct queue));
ptr->x=no;
ptr->next=NULL;
if(front==NULL)
{
front=ptr;
rear=ptr;
}
else
{
rear->next=ptr;
rear=ptr;
}
}
void delnode()
{
int p;
queue *ptr;
if(front==NULL)
{
cout<<"nnQueue is Empty";
return;
}
p=front->x; //strcpy(p,front->n)
ptr=front;
front=front->next;
delete ptr;
cout<<"nndeleted element "<<p<<"n";
}
void display()
{
queue *ptr;
cout<<"nQueue now:- n";
for(ptr=front;ptr!=NULL;ptr=ptr->next)
cout<<" "<<ptr->x;
}
OUTPUT
Q.19Enter two arrays and the output will be the merge of two
arrays .
# include <iostream.h>
# include <conio.h>
main()
{
int arr1[100],arr2[100],arr3[100],c,i=0,j=0,k=0,size1,size2;
clrscr();
cout<<"n enter no of element of arr1 ";
cin>>size1;
for (i=0;i<size1;i++)
{
cout<<"n enter no. ";
cin>>arr1[i];
}
cout<<"n enter no of element of arr2 ";
cin>>size2;
for (i=0;i<size2;i++)
{
cout<<"n enter no. ";
cin>>arr2[i];
}
cout<<"n arr1 ";
for (i=0;i<size1;i++)
cout<<" "<<arr1[i];
cout<<"n arr2 ";
for (i=0;i<size2;i++)
cout<<" "<<arr2[i];
i=0;j=0;k=0;
while (i<size1 && j<size2)
{
if (arr1[i]<arr2[j])
arr3[k++]=arr1[i++];
else if (arr2[j]<arr1[i])
arr3[k++]=arr2[j++];
else
i++;
}
while (i<size1)
arr3[k++]=arr1[i++];
while (j<size2)
arr3[k++]=arr2[j++];
cout<<"n arr3 ";
for (i=0;i<k;i++)
cout<<" "<<arr3[i];
getch();
}
OUTPUT
Q20.Sequence Sort (Insertion Sort)
#include<iostream.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,t;
clrscr();
cout<<"nEnter no of elements in A ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"nEnter no ";
cin>>a[i];
}
cout<<"nn";
for(i=0;i<n;i++)
cout<<" "<<a[i];
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
cout<<"nn";
for(i=0;i<n;i++)
cout<<" "<<a[i];
getch();
}
OUTPUT
My SQL
School homework
QUERIES
Ques 1. mysql> select ename ,sal,dept_no from empl
where commission is null ;
Ques 2. mysql> select ename ,sal,dept_no from empl where
commission is not null;
Ques 3. mysql> select * from empl where sal between
1000 and 2500;
Ques 4. mysql> select ename from empl where ename like
‘a%’ ;
Ques 5 . mysql> select concat (ename,dept_no)as “name
dept” from empl;
Ques 6 . mysql> select lower(ename) “empl name” from
empl;
Ques 7 . mysql> select upper(ename) “empl name” from
empl;
Ques 8 . mysql> select substr(job,1,5) from empl where
empno=8888 or empno=8900;
Ques 9 . mysql> select job,instr (job,’le’)as “le in ename”
from empl;
Ques 10 . mysql> select ename, length (ename)as “name
length” from empl where empno <=8888 ;
OUTPUT QUESTIONS
Ques 1 . mysql> select left(‘Informatices practices’,5) ;
Ques 2 . mysql> select right (‘Informatices practices’,5);
Ques 3 . mysql> select mid(‘Informatices practices’,6,9);
Ques 4 . mysql> select ltrim(‘ akshit’);
Ques 5 . mysql> select rtrim(‘akshit ‘);
Practical Class 12th (c++programs+sql queries and output)

Contenu connexe

Tendances

COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual finalAhalyaR
 
programming in C++ report
programming in C++ reportprogramming in C++ report
programming in C++ reportvikram mahendra
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointersSushil Mishra
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservationSwarup Kumar Boro
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
C++ project
C++ projectC++ project
C++ projectSonu S S
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nmmohamed sikander
 
Computer Graphics Lab
Computer Graphics LabComputer Graphics Lab
Computer Graphics LabNeil Mathew
 

Tendances (20)

COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 
C++ file
C++ fileC++ file
C++ file
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
programming in C++ report
programming in C++ reportprogramming in C++ report
programming in C++ report
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
C++ project
C++ projectC++ project
C++ project
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Array notes
Array notesArray notes
Array notes
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Arrays
ArraysArrays
Arrays
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
Computer Graphics Lab
Computer Graphics LabComputer Graphics Lab
Computer Graphics Lab
 

En vedette

Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Abdul Hannan
 
Lab manual of C++
Lab manual of C++Lab manual of C++
Lab manual of C++thesaqib
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
Chemistry Practical Record Full CBSE Class 12
Chemistry Practical Record Full CBSE Class 12 Chemistry Practical Record Full CBSE Class 12
Chemistry Practical Record Full CBSE Class 12 Muhammad Jassim
 
Computer science project work
Computer science project workComputer science project work
Computer science project workrahulchamp2345
 

En vedette (6)

Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
 
practical file for class 12
practical file for class 12practical file for class 12
practical file for class 12
 
Lab manual of C++
Lab manual of C++Lab manual of C++
Lab manual of C++
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
Chemistry Practical Record Full CBSE Class 12
Chemistry Practical Record Full CBSE Class 12 Chemistry Practical Record Full CBSE Class 12
Chemistry Practical Record Full CBSE Class 12
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 

Similaire à Practical Class 12th (c++programs+sql queries and output)

c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
a) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdfa) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdfanuradhasilks
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operatorsHarleen Sodhi
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfMuhammadMaazShaik
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++Marco Izzotti
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab FileKandarp Tiwari
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfyamew16788
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CSAAKASH KUMAR
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdfYashMirge2
 
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
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 

Similaire à Practical Class 12th (c++programs+sql queries and output) (20)

Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
 
C++ file
C++ fileC++ file
C++ file
 
a) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdfa) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdf
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdf
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
java-programming.pdf
java-programming.pdfjava-programming.pdf
java-programming.pdf
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdf
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdf
 
C++ programming pattern
C++ programming patternC++ programming pattern
C++ programming pattern
 
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)
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 

Dernier

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Dernier (20)

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

Practical Class 12th (c++programs+sql queries and output)

  • 1. COMPUTER SCIENCE Practical File On C++ PROGRAMS & MY SQL ROLL NO . :- Class – Submitted By :- C++ PROGRAMS
  • 2. INDEX Q1.Enter name , age and salary and display it by using outside the class member . Q2. Program which gives the squares of all the odd numbers stored in an array . Q3.Program to store numbers in an array and allow user to enter any number which he/she wants to find in array .(Binary Search) Q4.Program for copy constructor . Q5.Enter numbers in an array in any order and it will give the output of numbers in ascending order . Q6. Enter any number from 2 digit to 5 digit and the output will be the sum of all the distinguish digits of the numbers . Q7.Enter rows and columns and the output will be the sum of the diagonals . Q8. Enter item no. , price and quantity in a class . Q9.Enter any line or character in a file and press * to exit the program . Q10. Program will read the words which starts from vowels stored in a file . Q11. Enter employee no , name , age , salary and store it in a file.
  • 3. Q12. Deleting the information of employee by entering the employee number . Q13. Enter any number and its power and the output will the power of the number . Q14. Enter 3 strings and the output will show the longest string and the shortest string . Q.15 Enter any number and the output will be all the prime numbers up to that number . Q16. Selection sort Q17. Using loop concept the program will give the output of numbers making a right triangle . Q18. Program for Stacks and Queue . Q.19Enter two arrays and the output will be the merge of two arrays . Q20. Sequence sort . Q.SQL QUERIES AND OUTPUT . Q1.Enter name , age and salary and display it by using outside the class member . #include<iostream.h> #include<conio.h> class abc
  • 4. { //private: char n[20]; int a; float sal; public: void getdata(void) { cout<<"nEnter name "; cin>>n; cout<<"nEnter age "; cin>>a; cout<<"nEnter salary "; cin>>sal; } void putdata(void) { cout<<"nnNAME IS "<<n; cout<<"nAGE IS "<<a; cout<<"nSALARY IS "<<sal; } }; main() { abc p; clrscr(); p.getdata(); p.putdata(); getch(); }
  • 6. Q2. Program which gives the squares of all the odd numbers stored in an array . #include<iostream.h> #include<conio.h> main() { int a[20],i,x; clrscr(); cout<<"nEnter no of elements "; cin>>x; for(i=0;i<x;i++) { cout<<"nEnter no "; cin>>a[i]; } cout<<"nnArr1: "; for(i=0;i<x;i++) cout<<" "<<a[i]; cout<<"nnArr1: "; for(i=0;i<x;i++) { if(a[i]%2==1) a[i]=a[i]*a[i]; cout<<" "<<a[i]; } getch(); }
  • 8. Q3.Program to store numbers in an array and allow user to enter any number which he/she wants to find in array .(Binary Search) #include<iostream.h> #include<conio.h> main() { int a[20],n,i,no,low=0,high,mid,f=0; clrscr(); cout<<"nEnter no of elements "; cin>>n; for(i=0;i<n;i++) { cout<<"nEnter no "; cin>>a[i]; } cout<<"nn"; for(i=0;i<n;i++) cout<<" "<<a[i]; cout<<"nEnter no to be search "; cin>>no; high=n-1; while(low<=high && f==0) { mid=(low+high)/2; if(a[mid]==no) { cout<<"nn"<<no<<" store at "<<mid+1; f=1; break; } else if(no>a[mid]) low=mid+1; else high=mid-1; } if(f==0) cout<<"nn"<<no<<" does not exist"; getch(); }
  • 10. Q4.Program for copy constructor . #include<iostream.h> #include<conio.h> #include<string.h> class data { char n[20]; int age; float sal; public: data(){} data(char x[],int a,float k) { strcpy(n,x); age=a; sal=k; } data(data &p) { strcpy(n,p.n); age=p.age;//+20; sal=p.sal;//+1000; } display() { cout<<"nnNAME : "<<n; cout<<"nnAGE : "<<age; cout<<"nnSalary: "<<sal; } }; main() { clrscr(); data d("ajay",44,5000); //implicit caling data d1(d); data d2=d; data d3; d3=d2; d.display(); d1.display(); d2.display();
  • 11. d3.display(); getch(); } OUTPUT Q5.Enter numbers in an array in any order and it will give the output of numbers in ascending order .(Bubble Sort)
  • 12. #include<iostream.h> #include<conio.h> void main() { int a[20],n,i,j,t; clrscr(); cout<<"nEnter no of elements in A "; cin>>n; for(i=0;i<n;i++) { cout<<"nEnter no "; cin>>a[i]; } cout<<"nn"; for(i=0;i<n;i++) cout<<" "<<a[i]; for(i=0;i<n;i++) for(j=0;j<n-i-1;j++) if(a[j]>a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } cout<<"nn"; for(i=0;i<n;i++) cout<<" "<<a[i]; getch(); } OUTPUT
  • 13. Q6. Enter any number from 2 digit to 5 digit and the output will be the sum of all the distinguish digits of the numbers . #include<iostream.h> #include<conio.h>
  • 14. main() { int a=0,b=0,c; clrscr(); cout<<"nEnter value for A "; cin>>a; while(a>0) // for(;a>0;) or for(i=a;i>0;i=i/10) { c=a%10; b=b+c; a=a/10; } cout<<"nSum of digits "<<b; getch(); } OUTPUT Q7.Enter rows and columns and the output will be the sum of the diagonals . #include<iostream.h> #include<conio.h> main() {
  • 15. int a[10][10],i,j,r,c; clrscr(); cout<<"nEnter no of rows "; cin>>r; cout<<"nEnter no of Col "; cin>>c; for(i=0;i<r;i++) for(j=0;j<c;j++) { cout<<"nEnter no "; cin>>a[i][j]; } int sum=0,sum1=0; for(i=0;i<r;i++) { cout<<"n"; for(j=0;j<c;j++) { cout<<" "<<a[i][j]; /// if(i==j) //&& a[i][j]>0) // cout<<a[i][j]; // else // cout<<" "; //sum=sum+a[i][j]; /* if(i+j==r-1)// && a[i][j]>0) cout<<a[i][j]; else cout<<" "; */ if(i==j) sum1=sum1+a[i][j]; } } for(i=0;i<r;i++) { cout<<"n"; for(j=0;j<c;j++) { // cout<<" "<<a[i][j]; /* if(i==j) //&& a[i][j]>0) cout<<a[i][j]; else cout<<" ";*/ //sum=sum+a[i][j]; if(i+j==r-1)// && a[i][j]>0)
  • 16. // cout<<a[i][j]; // else // cout<<" "; sum=sum+a[i][j]; } } cout<<"nnFirst diagonal sum "<<sum1; cout<<"nnSecond diagonal sum "<<sum; getch(); } OUTPUT Q8. Enter item no. , price and quantity in a class . #include<iostream.h> #include<conio.h> class dd {
  • 17. char item[20]; int pr,qty; public: void getdata(); void putdata(); }; void dd::getdata() { cout<<"nEnter item name "; cin>>item; cout<<"nEnter price "; cin>>pr; cout<<"nEnter quantity "; cin>>qty; } void dd::putdata() { cout<<"nnItem name:"<<item; cout<<"nnPrice: "<<pr; cout<<"nnQty:"<<qty; } main() { dd a1,o1,k1; clrscr(); a1.getdata(); o1.getdata(); k1.getdata(); a1.putdata(); o1.putdata(); k1.putdata(); getch(); } OUTPUT
  • 18. Q9.Enter any line or character in a file and press * to exit the program .
  • 19. #include<iostream.h> #include<fstream.h> #include<conio.h> main() { char ch; clrscr(); ofstream f1("emp"); //implicit //ofstream f1; //f1.open("emp",ios::out); //explicit cout<<"nEnter char "; while(1) //infinity { ch=getche(); // to input a single charactor by keybord. if(ch=='*') break; if(ch==13) { cout<<"n"; f1<<'n'; } f1<<ch; } f1.close(); //getch(); } OUTPUT
  • 20. Q10. Program will read the words which starts from vowels stored in a file .
  • 21. #include<iostream.h> #include<fstream.h> #include<conio.h> main() { char ch[80]; int cnt=0; clrscr(); ifstream f1("emp"); ofstream f2("temp"); while(!f1.eof()) { f1>>ch; cout<<ch<<"n"; if(ch[0]=='a' || ch[0]=='e' || ch[0]=='o' || ch[0]=='i' || ch[0]=='u') f2<<"n"<<ch; } f1.close(); f2.close(); cout<<"nnName start with vowels nn"; f1.open("temp",ios::in); while(f1) //while(!f1.eof()) { f1>>ch; cout<<"n"<<ch; if(f1.eof()) break; } f1.close(); getch(); } OUTPUT
  • 22. Q11. Enter employee no , name , age , salary and store it in a file. #include<iostream.h>
  • 23. #include<conio.h> #include<fstream.h> int row=5,col=2; class abc { private: int empno; char n[20]; int age; float sal; public: void getdata() { char ch; cin.get(ch); // To empty buffer cout<<"nEnter employee no "; cin>>empno; cout<<"nEnter name "; cin>>n; cout<<"nEnter age "; cin>>age; cout<<"nEnter salary "; cin>>sal; } void putdata() { // gotoxy(col,row); cout<<"n"<<empno; // gotoxy(col+10,row); cout<<"t"<<n; // gotoxy(col+25,row); cout<<"t"<<age; // gotoxy(col+35,row); cout<<"t"<<sal; // row++; } }; main() { clrscr(); abc p,p1; fstream f1("emp5.txt",ios::in|ios::out|ios::binary); int i; for(i=0;i<3;i++) {
  • 25.
  • 26. Q12. Deleting the information of employee by entering the employee number . #include<iostream.h> #include<conio.h> #include<fstream.h> #include<stdio.h> class abc { private: int empno; char n[20]; int age; float sal; public: void getdata() { cout<<"nEnter employee no "; cin>>empno; cout<<"nEnter name "; cin>>n; cout<<"nEnter age "; cin>>age; cout<<"nEnter salary "; cin>>sal; } void putdata() { cout<<"nn"<<empno<<"t"<<n<<"t"<<age<<"t"<<sal; } int get_empno() { return empno; } }; main() { abc p,p1; clrscr(); ifstream f1("emp5.txt",ios::in|ios::binary); ofstream f2("temp",ios::out|ios::binary); int i,emp; cout<<"nnNAMEtAGEtSALARY";
  • 27. f1.clear(); f1.seekg(0); //for(i=0;i<4;i++) while(!f1.eof()) { f1.read((char*)&p1,sizeof(p1)); if(f1.eof()) break; p1.putdata(); } cout<<"nEnter employee no "; cin>>emp; f1.clear(); f1.seekg(0); //while(f1) while(!f1.eof()) { f1.read((char*)&p1,sizeof(p1)); if(f1.eof()) break; if(emp!=p1.get_empno()) f2.write((char*)&p1,sizeof(p1)); } f1.close(); f2.close(); remove("emp5.txt"); rename("temp","emp5.txt"); f1.open("emp5.txt",ios::in|ios::binary); cout<<"nnNAMEtAGEtSALARY"; f1.seekg(0); //for(i=0;i<3;i++) while(!f1.eof()) { f1.read((char*)&p1,sizeof(p1)); if(f1.eof()) break; p1.putdata(); } f1.close(); getch(); }
  • 28. OUTPUT Q13. Enter any number and its power and the output will the power of the number . #include<iostream.h>
  • 29. #include<conio.h> #include<math.h> #define CUBE(a,b) pow(a,b) //a>b?a:b main() { int x,y,z; clrscr(); cout<<"nEnter base value "; cin>>x; cout<<"nEnter power "; cin>>y; z=CUBE(x,y); cout<<"n"<<z; getch(); } OUTPUT Q14. Enter 3 strings and the output will show the longest string and the shortest string . #include<iostream.h> #include<conio.h> #include<string.h>
  • 30. main() { char n[20],n1[20],n2[20]; int l1,l2,l3; clrscr(); cout<<"nEnter String1 "; cin>>n; cout<<"nEnter String2 "; cin>>n1; cout<<"nEnter String3 "; cin>>n2; l1=strlen(n); l2=strlen(n1); l3=strlen(n2); (l1>l2 && l1>l3) ?cout<<"nLong: "<<n:(l2>l1 && l2>l3) ? cout<<"nLong: "<<n1 :cout<<"nLong: "<<n2; (l1<l2 && l1<l3)?cout<<"nshort:"<<n:(l2<l1 && l2<l3)? cout<<"nshort:"<<n1:cout<<"nshort:"<<n2; getch(); } OUTPUT
  • 31. Q.15 Enter any number and the output will be all the prime numbers up to that number . #include<iostream.h> #include<conio.h>
  • 32. main() { int n,i,j,p; clrscr(); cout<<"nEnter no of N "; cin>>n; for(i=1;i<=n;i++) { p=0; for(j=2;j<=i/2;j++) if(i%j==0) p=1; if(p==0) cout<<" "<<i; } getch(); } OUTPUT Q16. Selection sort #include<iostream.h> #include<conio.h> void main() {
  • 33. int a[20],n,i,j,t,min,p; clrscr(); cout<<"nEnter no of elements in A "; cin>>n; for(i=0;i<n;i++) { cout<<"nEnter no "; cin>>a[i]; } cout<<"nn"; for(i=0;i<n;i++) cout<<" "<<a[i]; for(i=0;i<n;i++) { min=a[i]; p=i; for(j=i;j<n;j++) { if(a[j]<min) { min=a[j]; p=j; } } t=a[i]; a[i]=a[p]; a[p]=t; } cout<<"nn"; for(i=0;i<n;i++) cout<<" "<<a[i]; getch(); } OUTPUT
  • 34. Q17. Using loop concept the program will give the output of numbers making a right triangle . #include<iostream.h> #include<conio.h>
  • 35. main() { int i,j; clrscr(); for(i=1;i<=4;i++) { cout<<"nn"; for(j=1;j<=i;j++) cout<<" "<<i; } getch(); } OUTPUT Q18. Program for Stacks and Queue . #include<iostream.h> #include<conio.h> #include<stdlib.h> struct queue
  • 36. { int x; queue *next; }*front=NULL,*rear; void insert(int); void delnode(); void display(); void main() { int a,ch; clrscr(); do { cout<<"nEnter 1 for Insert"; cout<<"nEnter 2 for Delete"; cout<<"nEnter 3 for display"; cout<<"nEnter 4 for exit"; cout<<"nnEnter your choice "; cin>>ch; switch(ch) { case 1: cout<<"nEnter no for insert "; cin>>a; insert(a); break; case 2: delnode(); break; case 3: display(); break; case 4: exit(0); } } while(1); getch(); } void insert(int no) // char str[] { queue *ptr; ptr=new queue; // strcpy(ptr->n,str) // ptr=(struct queue*)malloc(sizeof(struct queue)); ptr->x=no; ptr->next=NULL; if(front==NULL) {
  • 37. front=ptr; rear=ptr; } else { rear->next=ptr; rear=ptr; } } void delnode() { int p; queue *ptr; if(front==NULL) { cout<<"nnQueue is Empty"; return; } p=front->x; //strcpy(p,front->n) ptr=front; front=front->next; delete ptr; cout<<"nndeleted element "<<p<<"n"; } void display() { queue *ptr; cout<<"nQueue now:- n"; for(ptr=front;ptr!=NULL;ptr=ptr->next) cout<<" "<<ptr->x; } OUTPUT
  • 38.
  • 39. Q.19Enter two arrays and the output will be the merge of two arrays .
  • 40. # include <iostream.h> # include <conio.h> main() { int arr1[100],arr2[100],arr3[100],c,i=0,j=0,k=0,size1,size2; clrscr(); cout<<"n enter no of element of arr1 "; cin>>size1; for (i=0;i<size1;i++) { cout<<"n enter no. "; cin>>arr1[i]; } cout<<"n enter no of element of arr2 "; cin>>size2; for (i=0;i<size2;i++) { cout<<"n enter no. "; cin>>arr2[i]; } cout<<"n arr1 "; for (i=0;i<size1;i++) cout<<" "<<arr1[i]; cout<<"n arr2 "; for (i=0;i<size2;i++) cout<<" "<<arr2[i]; i=0;j=0;k=0; while (i<size1 && j<size2) { if (arr1[i]<arr2[j]) arr3[k++]=arr1[i++]; else if (arr2[j]<arr1[i]) arr3[k++]=arr2[j++]; else i++; } while (i<size1) arr3[k++]=arr1[i++]; while (j<size2) arr3[k++]=arr2[j++];
  • 41. cout<<"n arr3 "; for (i=0;i<k;i++) cout<<" "<<arr3[i]; getch(); } OUTPUT Q20.Sequence Sort (Insertion Sort) #include<iostream.h> #include<conio.h> void main()
  • 42. { int a[20],n,i,j,t; clrscr(); cout<<"nEnter no of elements in A "; cin>>n; for(i=0;i<n;i++) { cout<<"nEnter no "; cin>>a[i]; } cout<<"nn"; for(i=0;i<n;i++) cout<<" "<<a[i]; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(a[i]>a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } cout<<"nn"; for(i=0;i<n;i++) cout<<" "<<a[i]; getch(); } OUTPUT
  • 44. School homework QUERIES Ques 1. mysql> select ename ,sal,dept_no from empl where commission is null ;
  • 45. Ques 2. mysql> select ename ,sal,dept_no from empl where commission is not null; Ques 3. mysql> select * from empl where sal between 1000 and 2500;
  • 46. Ques 4. mysql> select ename from empl where ename like ‘a%’ ; Ques 5 . mysql> select concat (ename,dept_no)as “name dept” from empl;
  • 47. Ques 6 . mysql> select lower(ename) “empl name” from empl; Ques 7 . mysql> select upper(ename) “empl name” from empl;
  • 48. Ques 8 . mysql> select substr(job,1,5) from empl where empno=8888 or empno=8900; Ques 9 . mysql> select job,instr (job,’le’)as “le in ename” from empl;
  • 49. Ques 10 . mysql> select ename, length (ename)as “name length” from empl where empno <=8888 ;
  • 50. OUTPUT QUESTIONS Ques 1 . mysql> select left(‘Informatices practices’,5) ; Ques 2 . mysql> select right (‘Informatices practices’,5); Ques 3 . mysql> select mid(‘Informatices practices’,6,9);
  • 51. Ques 4 . mysql> select ltrim(‘ akshit’); Ques 5 . mysql> select rtrim(‘akshit ‘);