// PROGRAMME BY MENU DRIVEN FOR THR ARRAY
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,choice,odd,even,sum,high,low;
int a[10];
float avg;
char ch ;
ch='y';
sum=0;
cout<<"\n\n"<< "*******ENTER THE ARRAY(Size=10)******* ";
for(i=0;i<10;i++)
{
cin>>a[i];
}
do
{
cout<<"\n ENTER IF YOU WANT FOLLOWING:-";
cout<<"\n ******1 FOR THE PRINT THE EVEN - VALUED ELEMENTS*******";
cout<<"\n\n"<<"**2 FOR THE PRINT THE ODD - VALUED ELEMENTS*******";
cout<<"\n\n"<<"**3 FOR THE CALC & PRINT THE SUM & AVERAGE OF THE ELEMENTS OF ARRAY*******";
cout<<"\n\n"<<"**4 FOR THE PRINT MAX & MIN VALUE IN THE ARRAY*******";
cout<<"\n\n"<<"**5 FOR THE PRINT ARRAY IN REVERSE ORDER*******";
cin>>choice;
if(choice==1)
{
for(i=0;i<10;i++)
{
if(a[i]%2==0)
cout<<"\n AN EVEN VALUE ELEMENT ARE ="<<a[i];
}
}
if(choice==2)
{
for(i=0;i<10;i++)
{
if(a[i]%2!=0)
cout<<"\n THE ODD VALUE ELEMENT ARE ="<<a[i];
}
}
if(choice==3)
{
avg=0.0;
for(i=0;i<10;i++)
{
sum=sum+a[i];
}
cout<<"\n"<<"SUM="<<sum;
avg=sum/10;
cout<<"\n AVERAGE IS="<<avg;
}
if(choice==4)
{
high=a[0];
low=a[0];
for(i=0;i<10;i++)
{
if(a[i]>high)
{
high=a[i];
}
if(a[i]<low)
{
low=a[i];
}
}
cout<<"\nTHE HIGHEST NO. IS="<<high;
cout<<"\nLOWEST NO. IS="<<low;
}
if(choice==5)
{
for(i=9;i>=0;i--)
cout<<"\t "<<a[i];
}
cout<<"\n\n IF YOU WANT TO CONTINUE ENTER Y ELSE N";
cin>>ch;
}while(ch=='y'||ch=='Y');
getch();
}
2 comments:
Heya i am for the first time here. I came across this board and I find It truly useful & it helped me out
much. I hope to give something back and help others like you helped me.
http://vhstodvdreviews.com
Sure, it's all my pleasure.
Our motive is just to distribute computer knowledge across the world.
We will try to help other as much as we can.
Thank you very much for your feedback,stay with us
Post a Comment