Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1.

How to make sequential value : 10,20,30,40,50


#include <iostream>
 using namespace std;

void num (int i, int u){


for (i = 10; i <= u; i++){
cout << i << " , ";
 }
}

int main ()
{
   num (10,50);
}

////OR////

#include <iostream>
using namespace std;
int main()
{
cout << "10,20,30,40,50,60,70";
return 0;
}
2. HOW TO FIND THE MINIMUM AND MAXIMUM VALUE IN THE MATRIX USING C++

#include<iostream>

using namespace std;


int main()

int m,n,a[10][10],i,j,high,low;

cout<<"=========HOW TO FIND THE MINIMUM AND MAXIMUM VALUE IN


MATRIX========== \n";

cout<<"\nEnter how many Rows and coloumns Sequentially (Hit the enter for the
next step):";

cin>>m>>n;

cout<<"\nEnter matrix:\n";

for(i=0;i<m;++i)

for(j=0;j<n;++j)

cin>>a[i][j];

high=a[0][0];

low=a[0][0];

for(i=0;i<m;++i)

{
for(j=0;j<n;++j)

if(a[i][j]>high)

high=a[i][j];

else

if(a[i][j]<low)

low=a[i][j];

cout<<"\nHighest value:"<<high<<"\n\nLowest Value:"<<low<<"\n";

return 0;

3. How to calculate an average from an array


#include <iostream>
 using namespace std;

int main()
{
int n, i;
float num[1000], sum=0.0, average;

cout << "Enter the numbers of data: ";


cin >> n;

while (n > 1000 || n <= 0)


{
cout << "Error! number should in range of (1 to 1000).\n";
cout << "Enter the number again: ";
cin >> n;
}

for(i = 0; i < n; i++)


{
cout << i + 1 << ". Enter number: ";
cin >> num[i];
sum += num[i];
}

average = sum / n;
cout << "Average = " << average;

return 0;
}

You might also like