Prac 6 CPP
Prac 6 CPP
Prac 6 CPP
OUTPUT:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,count,n[5],freq[5];
cout<<"enter the number of element in an array:";
for(i=0;i<5;i++)
{
cin>>a[i];
freq[i]=-1;
}
for(i=0;i<5;i++)
{
count=1;
for(j=i+1;j<5;j++)
{
if(a[i]==a[j])
{
count++;
freq[j]=0;
}
}
if(freq[i]!=0)
{
freq[i]=count;
}
}
cout<<"the frequency of the elements of thus array is:"<<endl;
for(i=0;i<5;i++)
{
if(freq[i]!=0)
{
cout<<a[i]<<"occurs"<<freq[i]<<"times"<<endl;
}
}
OUTPUT:
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN
#include <iostream.h>
#include<conio.h>
void main()
clrscr();
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
min=max=a[0];
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN
for(i=1;i<n;i++)
if(min>a[i])
min=a[i];
if(max <a[i])
max=a[i];
OUTPUT:
#include<iostream.h>
#include<conio.h>
void main()
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN
{
int a[10],size,i,num,flag=0;
cout<<"enter the size of array:";
cin>>size;
cout<<"enter"<<size<<"array elements one by one:";
for(i=0;i<size;i++)
{
cin>>a[i];
}
cout<<"enter the number you want to check";
cin>>num;
for(i=0;i<size;i++)
{
if(num==a[i])
{
flag++;
}
}
if(flag>0)
{
cout<<"the number"<<num<<"is present in the array:";
}
else
{
cout<<"the number"<<num<<"is not present in the array";
}
}
OUPUT:
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10],i;
cout<<"enter the elements of array";
for(i=0;i<10;i++)
{
cin>>a[i];
}
cout<<"even number of array are:";
for(i=0;i<10;i++)
{
if(a[i]%2==0){
cout<<a[i]<<endl;
}
}
cout<<"odd number of array are";
for(i=0;i<=10;i++){
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN
if(a[i]%2==1){
cout<<a[i]<<endl;
}
}
}
OUTPUT:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10],i,pos,elem,tot;
cout<<"enter 9 array elements";
for(i=0;i<9;i++)
cin>>a[i];
cout<<"enter element to insert:";
cin>>elem;
cout<<"at what position?";
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN
cin>>pos;
for(i=10;i>=pos;i--)
a[i]=a[i-1];
a[i]=elem;
tot++;
cout<<"the new array is:";
for(i=0;i<10;i++)
cout<<a[i]<<" ";
cout<<endl;
}
OUTPUT:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN
int a[10],tot=10,i,elem,j,found;
cout<<"enter 10 elements";
for(i=0;i<tot;i++)
cin>>a[i];
for(i=0;i<tot;i++)
{
if(a[i]==elem)
{
for(j=1;j<(tot-1);j++)
a[j]==a[j+1];
found++;
i--;
tot--;
}
}
cout<<"the new array is:";
for(i=0;i<tot;i++)
cout<<a(i)<<" ";
}
}
OUTPUT:
#include<iostream.h>
#include<conio.h>
void main()
{
int arr[10],tot=10,i,elem,j,found;
cout<<"Enter 10 elements:";
for(i=0;i<tot;i++)
cin>>arr[i];
cout<<"Enter elements to delete:";
cin>>elem;
for(i=0;i<tot;i++)
{
if(arr [i]==elem)
{
for(j=i;j<(tot-1);j++)
arr[i]=arr[j+1];
found=1;
i--;
tot--;
}
}
if(found==0)
cout<<"element not there in array";
else
cout<<"elements deleted successfully";
cout<<endl;
{
cout<<"the new array is:";
for(i=0;i<tot;i++)
cout<<arr[i]<<" ";
}
cout<<endl;
}
OUPUT:
FYCS15 PRACTICAL 6 SIDDHESH CHAVAN