0% found this document useful (0 votes)
80 views14 pages

Include

jj

Uploaded by

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

Include

jj

Uploaded by

Hari Tharan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

#include <iostream>

using namespace std;

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 :";
}

float add(float a, float b)


{
return a + b;
}

float subtract(float a, float b)


{
return a - b;
}

float multiply(float a, float b)


{
return a * b;
}

float divide(float a, float b)


{
return a / b;

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>

using namespace std;

void showChoices();

float add(float, float);

float subtract(float, float);

float multiply(float, float);

float divide(float, float);

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 mean of these input is "<< mean <<endl;

break;

case 6:

cout << "Invalid input" << endl;

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 ";

float add(float a, float b)

return a + b;

float subtract(float a, float b)

return a - b;

float multiply(float a, float b)

return a * b;

float divide(float a, float 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 ";
}

double deviation (double Arr[i], int n)


{
double deviation;
double sum2=0;

for ( int i = 0; i <=size; i++ )


{
sum2 += pow((x[i]-mean2),2);
}
deviation= sqrt(sum2/(size-1));
return deviation;
}

#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 ";
}

double deviation (double Arr[i], int n)


{
double deviation;
double sum2=0;

for ( int i = 0; i <=size; i++ )


{
sum2 += pow((x[i]-mean2),2);
}
deviation= sqrt(sum2/(size-1));
return deviation;

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 :";
}

float add(float a, float b)


{
return a + b;
}

float subtract(float a, float b)


{
return a - b;
}

float multiply(float a, float b)


{
return a * b;
}

float divide(float a, float b)


{
return a / b;
}

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 :";
}

float add(float a, float b)


{
return a + b;
}

float subtract(float a, float b)


{
return a - b;
}

float multiply(float a, float b)


{
return a * b;
}

float divide(float a, float b)


{
return a / b;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy