Professional Documents
Culture Documents
void showChoices();
float add(float, float);
float subtract(float, float);
float multiply(float, float);
float divide(float, float);
int main()
{
float x, y;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Sum " << add(x,y) <<endl;
break;
case 2:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Difference " << subtract(x,y) <<endl;
break;
case 3:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Product " << multiply(x,y) <<endl;
break;
case 4:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Quotient " << divide(x,y) <<endl;
break;
case 5:
break;
default:
cout << "Invalid input" << endl;
}
}while (choice != 5);
return 0;
}
void showChoices()
{
cout << "MENU" << endl;
cout << "1: Add " << endl;
cout << "2: Subtract" << endl;
cout << "3: Multiply " << endl;
cout << "4: Divide " << endl;
cout << "5: Exit " << endl;
cout << "Enter your choice :";
}
MENU
1: Add
2: Subtract
3: Multiply
4: Divide
5: Exit
Enter your choice :1
Enter two numbers: 12 24
Sum 36
MENU
1: Add
2: Subtract
3: Multiply
4: Divide
5: Exit
Enter your choice :2
Enter two numbers: 40 25
Difference 15
MENU
1: Add
2: Subtract
3: Multiply
4: Divide
5: Exit
Enter your choice :3
Enter two numbers: 8.6 2.4
Product 20.64
MENU
1: Add
2: Subtract
3: Multiply
4: Divide
5: Exit
Enter your choice :4
Enter two numbers: 10 4
Product 2.5
MENU
1: Add
2: Subtract
3: Multiply
4: Divide
5: Exit
Enter your choice :7
Invalid inp#include <iostream>
void showChoices();
int main()
int Arr[100],n,i,small,large;
float x, y,mean,sum;
int choice;
do
showChoices();
switch (choice)
case 1:
break;
case 2:
cin>>n;
for(i=0;i<n;i++)
cin>>Arr[i];
small=Arr[0];
large=Arr[0];
for(i=1;i<n;i++)
if(Arr[i]<small)
small=Arr[i];
if(Arr[i]>large)
large=Arr[i];
sum += Arr[i];
mean = sum/n;
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
return 0;
void showChoices()
return a + b;
return a - b;
return a * b;
return a / b;
}ut
#include <iostream>
#include <cmath>
using namespace std;
void showChoices();
double deviation(double[] , int);
double mean (double[] , int);
double mean2;
double deviation(const double , int);
double mean (const double , int);
int main()
{
int Arr[100],n,i,small,large;
float x, y,mean,sum;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Sum " << add(x,y) <<endl;
break;
case 2:
cout<<"Enter number of elements you want to insert ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter element "<<i+1<<":";
cin>>Arr[i];
}
small=Arr[0];
large=Arr[0];
for(i=1;i<n;i++)
{
if(Arr[i]<small)
small=Arr[i];
if(Arr[i]>large)
large=Arr[i];
}
for(i = 0; i <n; ++i)
{
sum += Arr[i];
mean = sum/n;
}
break;
case 3:
cout<<"The mean of these values are : "<<mean;
break;
case 4:
cout<<"\nLargest element is :"<<large;
cout<<"\nSmallest element is :"<<small;
break;
case 5:
cout << "The standard deviation is:"<<deviation (Arr[i],n);
break;
case 6:
break;
}
}while (choice != 6);
return 0;
}
void showChoices()
{
cout << "\nMENU" << endl;
cout << "1: showChoice " << endl;
cout << "2: enterData" << endl;
cout << "3: displayMean " << endl;
cout << "4: displayLowestHighest " << endl;
cout << "5: displayStd " << endl;
cout << "6:displayStdCategory ";
}
#include <iostream>
#include <cmath>
using namespace std;
void showChoices();
double deviation(double[] , int);
double mean (double[] , int);
double mean2;
double deviation(const double , int);
double mean (const double , int);
int main()
{
int Arr[100],n,i,small,large;
float x, y,mean,sum;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Sum " << add(x,y) <<endl;
break;
case 2:
cout<<"Enter number of elements you want to insert ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter element "<<i+1<<":";
cin>>Arr[i];
}
small=Arr[0];
large=Arr[0];
for(i=1;i<n;i++)
{
if(Arr[i]<small)
small=Arr[i];
if(Arr[i]>large)
large=Arr[i];
}
for(i = 0; i <n; ++i)
{
sum += Arr[i];
mean = sum/n;
}
for(i = 0; i < 10; ++i)
standardDeviation += pow(Arr[i] - mean, 2);
X= sqrt(standardDeviation /n)
break;
case 3:
cout<<"The mean of these values are : "<<mean;
break;
case 4:
cout<<"\nLargest element is :"<<large;
cout<<"\nSmallest element is :"<<small;
break;
case 5:
cout << "The standard deviation is:"<<deviation (Arr[i],n);
break;
case 6:
break;
}
}while (choice != 6);
return 0;
}
void showChoices()
{
cout << "\nMENU" << endl;
cout << "1: showChoice " << endl;
cout << "2: enterData" << endl;
cout << "3: displayMean " << endl;
cout << "4: displayLowestHighest " << endl;
cout << "5: displayStd " << endl;
cout << "6:displayStdCategory ";
}
final
#include <iostream>
#include <cmath>
using namespace std;
void showChoices();
double deviation(double[] , int);
double mean (double[] , int);
double mean2;
double deviation(const double , int);
double mean (const double , int);
int main()
{
int Arr[100],n,i,small,large;
float x, y,mean,sum;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter two numbers: ";
cin >> x >> y;
break;
case 2:
cout<<"Enter number of elements you want to insert ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter element "<<i+1<<":";
cin>>Arr[i];
}
small=Arr[0];
large=Arr[0];
for(i=1;i<n;i++)
{
if(Arr[i]<small)
small=Arr[i];
if(Arr[i]>large)
large=Arr[i];
}
for(i = 0; i <n; ++i)
{
sum += Arr[i];
mean = sum/n;
}
break;
case 3:
cout<<"The mean of these values are : "<<mean;
break;
case 4:
cout<<"\nLargest element is :"<<large;
cout<<"\nSmallest element is :"<<small;
break;
case 5:
break;
case 6:
break;
}
}while (choice != 6);
return 0;
}
void showChoices()
{
cout << "MENU" << endl;
cout << "1: showChoice " << endl;
cout << "2: enterData" << endl;
cout << "3: displayMean " << endl;
cout << "4: displayLowestHighest " << endl;
cout << "5: displayStd " << endl;
cout << "6:displayStdCategory ";
cout << "Enter your choice :";
}
Currently running
#include <iostream>
#include <cmath>
using namespace std;
void showChoices();
int main()
{
int Arr[100],n,i,small,large;
float x, y,mean,sum,total,deviation;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter two numbers: ";
cin >> x >> y;
break;
case 2:
cout<<"Enter number of elements you want to insert ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter element "<<i+1<<":";
cin>>Arr[i];
}
small=Arr[0];
large=Arr[0];
for(i=1;i<n;i++)
{
if(Arr[i]<small)
small=Arr[i];
if(Arr[i]>large)
large=Arr[i];
}
for(i = 0; i <n; ++i)
{
sum += Arr[i];
mean = sum/n;
}
for(i = 0; i<n ; i++)
{
total=pow((Arr[i]-mean),2);
deviation=sqrt(total/(n-1));
}
break;
case 3:
cout<<"The mean of these values are : "<<mean;
break;
case 4:
cout<<"\nLargest element is :"<<large;
cout<<"\nSmallest element is :"<<small;
break;
case 5:
cout<<"The standard deviation for this inputs is "<<deviation<<endl;
break;
case 6:
break;
}
}while (choice != 6);
return 0;
}
void showChoices()
{
cout << "MENU" << endl;
cout << "1: showChoice " << endl;
cout << "2: enterData" << endl;
cout << "3: displayMean " << endl;
cout << "4: displayLowestHighest " << endl;
cout << "5: displayStd " << endl;
cout << "6:displayStdCategory ";
cout << " \nEnter your choice :";
}