0% found this document useful (0 votes)
6 views2 pages

Modify Array Elements in C++

The document contains three C++ programs. The first program modifies a 5-element integer array by replacing positive numbers with 1 and negative numbers with 0. The second and third programs find the maximum and minimum values in a 5-element array, respectively, but contain syntax errors that need correction.

Uploaded by

tittechnocrats
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Modify Array Elements in C++

The document contains three C++ programs. The first program modifies a 5-element integer array by replacing positive numbers with 1 and negative numbers with 0. The second and third programs find the maximum and minimum values in a 5-element array, respectively, but contain syntax errors that need correction.

Uploaded by

tittechnocrats
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//wap to modify the array elemens.

in 5 element int array find positive number and


replaced it with 1 and find negative number and replaced it with 0.

#include <iostream>
int main()
{
int x[5],i;
cout<<"Enter 5 values";
for (i=0;i<5;i++)
{
cin>>x[i];
}
for (i=0;i<5;i++)
{
if (x[i]>0)
x[i]=1;
else
x[i]=0;
}
for (i=0;i<5;i++)
{
cout<<x[i]<<endl;
}
return0;
}

//wap to find maximum value from 5 element array.


include <iostream>
int main ()
{
int x[5],i,max;
cout<<"Enter 5 value";
for(i=0;i<5i++)
{
cin>>x[i];
}
max=x[0];
for(i=1;i<5;i++)
{
if(x[i]>max)
max=x[i];
}
cout<<" The Maximum value is"<<max;
return 0;
}

//wap to find minimum value from 5 element array.


include <iostream>
int main ()
{
int x[5],i,min;
cout<<"Enter 5 value";
for(i=0;i<5i++)
{
cin>>x[i];
}
min=x[0];
for(i=1;i<5;i++)
{
if(x[i]>min)
min=x[i];
}
cout<<" The Minimum value is"<<min;
return 0;
}

You might also like