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 :) !
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();
}
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
{
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>
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++];
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;
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 ;