0% found this document useful (0 votes)
3 views6 pages

Array Manipulation in C++

The document contains C++ code snippets for three different 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 from a 5-element array, respectively.

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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Array Manipulation in C++

The document contains C++ code snippets for three different 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 from a 5-element array, respectively.

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 PDF, TXT or read online on Scribd

TIT Bhopal

//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++)
{
TIT Bhopal
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 ()
{
TIT Bhopal
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;
}
TIT Bhopal

//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)
TIT Bhopal
min=x[i];
}
cout<<" The Minimum value
is"<<min;
return 0;
}
TIT Bhopal

You might also like