SlideShare a Scribd company logo
0
Gandhinagar
Ranchi
1
This is to certify that UTTAMGUPTA , a
student of class XII-S1 has successfully
completed the research on the below
mentioned project under the guidance of
Mr.Amit Dutta ( Subject Teacher ) during
the year 2017-2018 in Computer Practical
Examination conducted by CBSE, New
Delhi.
2
………………………………….
Signatureof ExternalExaminer
…………………………………..
Signatureof ComputerTeacher
UTTAM KUMAR GUPTA of Std. XII would
like to express my sincere thanks to my
computer teacher “Amit Sir” for assigning
me this project. I feel extremely lucky to
have been given a golden chance or
opportunity to work under such a highly
experienced teacher.
3
Secondly I would also like to thank all my
family members without whose support it
was impossible for me to complete this
project.
Last but not least I would also like to thank
all my friends provided me some suggestion
in completing this project.
Thank You!
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 .
4
Q6.Enter any numberfrom2 digit to 5 digitand the output
will be the sum ofall the distinguish digitsofthe 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.
5
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 .
……………………………………………………………………
6
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();
}
7
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();
}
9
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 d2=d;
data d3;
d3=d2;
d1.display();
d2.display();d3.display();
getch();
}
10
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();
}
11
Q6.Enter any numberfrom2 digit to 5 digitand the output
will be the sum ofall the distinguish digitsofthe numbers.
#include<iostream.h>
#include<conio.h>
void 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();
}
12
Q7.Enter rows and columns and the output will be the sum
of the diagonals .
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];
13
// 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();
}
14
Q8. Enteritemno., 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();
}
15
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();
}
16
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();
}
17
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();
18
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();
}
19
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";
20
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();
}
21
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();
}
22
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();
}
23
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();
}
24
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();
}
25
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();
}
26
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)
27
// 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;
}
28
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)
29
arr3[k++]=arr2[j++];
cout<<"n arr3 ";
for (i=0;i<k;i++)
cout<<" "<<arr3[i];
getch();
}
30
Q20.Sequence Sort(Insertion Sort)
#include<iostream.h>
#include<conio.h>
{
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();
}
……………………………………………………
31
Books
1.Sumita Arora
2.Arihant Solved Q/A
3.Togetherwith learning with C++
32

More Related Content

What's hot

Los dskn
Los dsknLos dskn
Los dskn
Brenda Jazmin
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 
Advance java
Advance javaAdvance java
Advance java
Vivek Kumar Sinha
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
Bhavesh Shah
 
Ch 4
Ch 4Ch 4
Ch 4
AMIT JAIN
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
Anushka Rai
 
programming in C++ report
programming in C++ reportprogramming in C++ report
programming in C++ report
vikram mahendra
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Salar Delavar Qashqai
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
Farhan Ab Rahman
 
ماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارامماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارام
Aram Jamal
 
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Salar Delavar Qashqai
 
C++ project
C++ projectC++ project
C++ project
Sonu S S
 
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Salar Delavar Qashqai
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
Salar Delavar Qashqai
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
kkkseld
 
662305 10
662305 10662305 10

What's hot (20)

Los dskn
Los dsknLos dskn
Los dskn
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
Advance java
Advance javaAdvance java
Advance java
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
 
Ch 4
Ch 4Ch 4
Ch 4
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 
programming in C++ report
programming in C++ reportprogramming in C++ report
programming in C++ report
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
ماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارامماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارام
 
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
 
C++ project
C++ projectC++ project
C++ project
 
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
662305 10
662305 10662305 10
662305 10
 

Similar to Computer Practical XII

Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
Aman Deep
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
Aman Deep
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
yash production
 
OOP.pptx
OOP.pptxOOP.pptx
OOP.pptx
SanketAde1
 
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
yamew16788
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Make Mannan
 
C++ file
C++ fileC++ file
Kirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third YearKirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third Year
dezyneecole
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
Farhan Ab Rahman
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
Mitul Patel
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
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
premrings
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
Ashwin Francis
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
Syed Umair
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
ssuserd6b1fd
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
Arun Umrao
 
Reshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third YearReshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third Year
dezyneecole
 
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
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
HIMANSUKUMAR12
 
Object Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileObject Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical File
Harjinder Singh
 

Similar to Computer Practical XII (20)

Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
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 Rajnandgaon
 
OOP.pptx
OOP.pptxOOP.pptx
OOP.pptx
 
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
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
 
C++ file
C++ fileC++ file
C++ file
 
Kirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third YearKirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third Year
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
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
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
 
Reshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third YearReshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third Year
 
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)
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
Object Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileObject Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical File
 

Recently uploaded

一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Boston Institute of Analytics
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
slg6lamcq
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 

Recently uploaded (20)

一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 

Computer Practical XII

  • 2. 1 This is to certify that UTTAMGUPTA , a student of class XII-S1 has successfully completed the research on the below mentioned project under the guidance of Mr.Amit Dutta ( Subject Teacher ) during the year 2017-2018 in Computer Practical Examination conducted by CBSE, New Delhi.
  • 3. 2 …………………………………. Signatureof ExternalExaminer ………………………………….. Signatureof ComputerTeacher UTTAM KUMAR GUPTA of Std. XII would like to express my sincere thanks to my computer teacher “Amit Sir” for assigning me this project. I feel extremely lucky to have been given a golden chance or opportunity to work under such a highly experienced teacher.
  • 4. 3 Secondly I would also like to thank all my family members without whose support it was impossible for me to complete this project. Last but not least I would also like to thank all my friends provided me some suggestion in completing this project. Thank You! 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 .
  • 5. 4 Q6.Enter any numberfrom2 digit to 5 digitand the output will be the sum ofall the distinguish digitsofthe 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.
  • 6. 5 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 . ……………………………………………………………………
  • 7. 6 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(); }
  • 8. 7 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(); }
  • 9. 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. 9 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 d2=d; data d3; d3=d2; d1.display(); d2.display();d3.display(); getch(); }
  • 11. 10 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(); }
  • 12. 11 Q6.Enter any numberfrom2 digit to 5 digitand the output will be the sum ofall the distinguish digitsofthe numbers. #include<iostream.h> #include<conio.h> void 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(); }
  • 13. 12 Q7.Enter rows and columns and the output will be the sum of the diagonals . 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];
  • 14. 13 // 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(); }
  • 15. 14 Q8. Enteritemno., 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(); }
  • 16. 15 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(); }
  • 17. 16 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(); }
  • 18. 17 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();
  • 19. 18 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(); }
  • 20. 19 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";
  • 21. 20 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(); }
  • 22. 21 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(); }
  • 23. 22 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(); }
  • 24. 23 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(); }
  • 25. 24 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(); }
  • 26. 25 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(); }
  • 27. 26 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)
  • 28. 27 // 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; }
  • 29. 28 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)
  • 30. 29 arr3[k++]=arr2[j++]; cout<<"n arr3 "; for (i=0;i<k;i++) cout<<" "<<arr3[i]; getch(); }
  • 31. 30 Q20.Sequence Sort(Insertion Sort) #include<iostream.h> #include<conio.h> { 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(); } ……………………………………………………
  • 32. 31 Books 1.Sumita Arora 2.Arihant Solved Q/A 3.Togetherwith learning with C++
  • 33. 32