#include <cstdlib>
#include <iostream>
void high_Tenp(int [],int);
void low_Tenp(int []);
void Average_Tenp(int [],int);
using namespace std;
int main(int argc, char *argv[])
{
cout<<"\t\t***********************************"<<endl
<<"\t\t TEMPRATURE CALCULATION SYSTEM "<<endl
<<"\t\t***********************************"<<endl<<endl;
int n;
cout<<"Enter the number of consecutive days to read their temperature : ";
cin>>n;
int x[n];
int i, j, tmp;
for(i=0;i<n;i++)
{
cout<<endl<<"Enter temperature for day "<<i+1<<" : ";
cin>>x[i];
}
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++)
{
if (x[j] > x[j+1])
{
tmp = x[j];
x[j] = x[j+1];
x[j+1] = tmp;
}
}
}
Average_Tenp(x,n);
high_Tenp(x,n);
low_Tenp(x);
system("pause");
}
void high_Tenp(int a[],int arraysize)
{
cout<<"The Higest Temprature is : "<<a[arraysize-1]<<endl;
}
void low_Tenp(int a[])
{
int b=0;
cout<<"The Lowest Temprature is : "<<a[b]<<endl;
}
void Average_Tenp(int a[],int arraysize)
{
int i;
double c=0;
for ( i = 0 ; i < arraysize ; i ++)
{
c=c+a[i];
}
c=c/i;
cout<<endl<<"The Average Temprature is : "<<c<<endl;
}
void swap(int *x, int *y) //function using pointers to interchange the values
{
int tmp;
if(*x > *y)
{
tmp = *x;
*x = *y;
*y = tmp;
}
}
We tried that Assignment Solution, Graded Discussion Solution,Announcement
Search with our Site
Custom Search
Thursday, April 26, 2012
CS201 Asignment # 2 Solution 2012
Labels:
CS201
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment