Showing posts with label source code for simple function of array. Show all posts
Showing posts with label source code for simple function of array. Show all posts

Saturday, 30 June 2012

simple program of c++ to understand the use array



This is the source code for understand the simple function of array.
Here we have to calculate the average temperature of 7 days using array in c++.
#include<iostream.h>
#include<conio.h>
main()
{
      float temp[7],sum=0;
      int i=0;
      while(i<=6)
      {
                 cout<<"enter the temp. of day"<<i+1<<"?"<<endl;
                 cin>>temp[i];
                sum=sum+temp[i];
                i++;
                }
                cout<<"\nAverage temperature :"<<sum/7.0;
             
                getch();
                }
End