Académique Documents
Professionnel Documents
Culture Documents
Q-1 Write a program to Insert elements in an array (elements are in sorted order ).
Q- 2 Write a program using function to search an element in an array by linear search method.
Q- 3 Write a program using function to search an element in an array by binary search method.
Q-4 Write a program using function to sort the elements of array by using Insertion sort method.
Q-5 Write a program using function to sort the elements of array by using selection sort method.
Q-6 Write a program using function to produces third array c( which should be in ascending order) by merging two arrays A
and B (which are I ascending order).(AS,AS,AS)
Q-7 Write a program using function o print the upper hall of the given matrix, where matrix is given by the user.
Q- 8 Write a program using function which accepts a matrix and its prints the left diagonal elements.
Q- 9 Write a program using function which accepts an integer array and exchanges the values of first half side elements with
the second half side elements of the array.
Q-10 Write a program using function which accepts an array and its size and rearrange the array in such a way that the
values of alternate locations are exchanged.
Q- 11 Write a program in C++ using function \which accepts an integer array and its size as arguments and assign the
elements into two-dimensional array of integers in the following format:
Q- 12 Write a program using function to find the sum of elements each row of an integer matrix passed as an argument.
Q- 15 Write an interactive menu driven program to implement stacks an (insert, delete and display),
Q- 18 Number of Characters.
Q- 23 Declare a structure “employee” consists of fields empno, name, salary. Write a program to input records of 10 employees
& display data of all the employees getting salary more than 10000.
Q-25 Write a program to count no. of words starting with "T" in a file “text1.txt”.
int beg,mid,last;
beg+0,last+n-1;
while(beg<+last)
{
mid+(beg+last)/2;
if(item==a[mid])
{
small=a[i];
pos=i;
for(int j=i+1;j<n;j++)
{
if(a[j]<small)
#include<iostream.h>
#include<conio.h>
void swap(int a[3],int n);
void main()
{
clrscr();
int a[3],n,i;
cout<<”|n enter the size of array:”;
cin>>n;
cout<<”\n enter the elements of array :” ;
for(i=0;i<n;i++)
cin>>a[i];
swap(a,n);
getch();
}
void swap(int a[3],int n)
{
int i,j,tmp;
for(i=0;i<n;i+=2)
{
j=i+1;
tmp=a[i];
a[i]=a[j];
a[j]=tmp;
}
#include<iostream.h>
#include<coino.h>
void fun(int A[10],int m);
void main()
{
clrscr();
int A[10],n;
cout<<”\n Enter the size of array :”;
cin >>n;
cout<<”\n Enter the elements of the array:”;
for(int i=o;i<n;i++)
cin>>A[i];
fun(A,n);
getch();
}
void fun(int A[10],int n)
{
Int A2[20][20],I,j;
Cout<<”\n the 2-D form of the array is :\n;
for(i=0<n;i++)
{
for(j=0;j<nj++)
{
#include<iostream.h>
#include<<conio.h>
void sum(int a[10][10],int m,int n);
void main()
{
clrscr():
int a[10][10],n,m,i,j;
cout<<”\n enter the number row and columns of the matrix:’;
cin>>m>>n;
cout<<”\n enter the elements of the matrix:”;
for(i=0;<m;i++)
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cin>>a[i][i];
}
cout<<”\n the matric\x is:”;
for(i=0;i<m;i++)
{
cout<<”\n”;
for(j=0;j<m;j++)
#include<iostream.h>
#include<conio.h>
struct stu
{
int rno;
flot m1,m2,m3;
};
Stu s[50],t1.t2;
void main()
}
clrscr();
int n;
int ndist=0,p=0;
float top1=0,p=0;
cout<<\n enter the number of students: “;
cin>>n;
for (inti=0;i<n;i++)
{
cout<<”\n enter rollno : ” ;
cin>>s[i].rno;
cout <<”n\ Enter marks in three subjects: ”;
cin>>s[i].m1>>s[1].m2>>s[i].m3;
}
for(i=0;i<n;i++)
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
const int obj=4;
const int n=3;
class student
{
intg rno;
char name[20];
float Marks[n];
float per;
char grade;
public;
vold getval();
vold calculate();
vold prnresult();
};
else
if(per<75)
grade=’c’;
#include<iostream.h>
#include<conio.h
#include<process.h>
constint size=20;
class stack
{
int stack [size];
int top;
public;
stack()
{
top=-1;
}
int push(int item);
int pop();
void display();
};
int stack:: push (int item)
{
if(top==size-1)
return-1;
else
{
top++;
stack[top]=ite,;
}
retum 0;
#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
int ch,i,top=-1,stack[5];
x:
cout<<endl<<endl;
cout<<"Enter Choice 1> Insert 2> Delete 3>exit "<<endl;
cin>>ch;
switch(ch)
{
case 1:
top++;
if(top<=4)
{
cout<<"Enter The Element"<<endl;
cin>>stack[top];
cout<<"The Stack is"<<endl;
for(i=0;i<=top;i++)
cout<<stack[i];
goto x;
}
else
{
cout<<" ************* Stack OVERFLOW ********** "<<endl;
goto x;}
case 3:
exit(0);
default :
cout<<"WRONG CHOICE !!!!!!!!!!! "<<endl;
goto x;
}
}
int main()
printf ("Some different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100,
100);
return 0;
#include<fstream.h>
#include<conio.h>
void main()
clrscr();
ofsteam f;
f.open(“New.text”);
char ch [80],ch1;
do
gets(ch);
f<<ch;
cin>>ch1;
while(ch1==‘y’||ch==’Y’);
f.close();
for(j=0;j<=(2*n)-2;j++)
{
a2[i][j]= ' ';
}
}
//STARTING
for(i=0;i<=(2*n)-2;i++)
{
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,x,n;
double sum=0,term=1;
cout<<"\nEnter the no of terms : ";
cin>>n;
cout<<"\nEnter the value of x : ";
cin>>x;
for(i=1;i<=n;i++)
{ term=term*x*x/((2*i)*(2*i-1));
sum=sum+term;
}
cout<<"\nThe sum of the series is :"<<sum;
getch();
}
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
void main()
{
clrscr();
ofstream f("text1.txt",ios::app);
char ch[80],c;
do{
cout<<"\nEnter the info in file:-\n";
gets(ch);
f<<ch<<"\n";
cout<<"\nWant to enter more info ?(Y/N) : ";
cin>>c;
}while(c=='y'||c=='Y');
cout<<"\n\n\t\tProcessing!!!Please Wait!!!";
delay(3000);
clrscr();
cout<<"\n\t\tFile successfully created, modified & saved!!!!!!";
f.close();
getch();
}
#include<fstream.h>
#include<ctype.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
void main()
{
clrscr();
ifstream f("text1.txt");
char ch;
int c=0,d=0;
if(!f)
{
cout<<"\nFile Absent\n";
getch();
exit(0);
}
while(!f.eof())
{
f.get(ch);
if(isupper (ch))
c++;
else
d++;
}
f.close();
cout<<"\nNumber of Uppercase alphabets in the file Text1.txt : "<<c;
cout<<"\nNumber of lowercase alphabets in the file Text1.txt : "<<d;
getch();
}
Submitted By : Tanisha Arora
Q-25 Write a program to count no. of words starting with "T" in a file
“text1.txt”.
#include<fstream.h>
#include<dos.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<ctype.h>
void main()
{
clrscr();
ifstream f1("text1.txt");
char ch[80];
int count=0;
if(!f1)
{
cout<<"\nFile is absent\n";
getch();
exit(0);
}
while(!f1.eof())
{
f1>>ch;
if(ch[0]=='T')
{
count++;
}}
cout<<"\nCounting....Please Wait!!!";
delay(3000);
clrscr();
cout<<"\nTotal number of words starting with 'T' is "<<count;
f1.close();
getch();
}
Submitted By : Tanisha Arora
OUTPUT (1)
The matrix is :
1 2 3
4 5 6
7 8 9
The upper half of the matrix is :
1 2 3
5 6
9_
Left diagonal is :
1
5
9_
12 12 12 12 12 11 11 11 11 11
Menu :
1. No of students passed with distinction.
2. No of students failed.
3. Details of the topper.
4. Exit
Enter your choice : 3
Details of the topper are :
Roll No. 12
Marks : 56 56 56
Percentage : 56
Menu :
1. No of students passed with distinction.
2. No of students failed.
3. Details of the topper.
4. Exit
Student 1
Enter data
Roll No. : 11
Name : Meenakshi
1. INSERTION
2. DELETION
3. DISPLAY
4. EXIT
Enter your choice (1-4) : 1
Characters: a A
Decimals: 1977 650000
Preceding with blanks: 1977
Preceding with zeros: 0000001977
Some different radices: 100 64 144 0x64 0144
floats: 3.14 +3e+000 3.141600E+000
Width trick: 10
A string