how can i make an array inside by a function?????

so that the value i will input will change....

I am using Borland C++.....

how can i start it????

  1. [SOLO] Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest temperatures for the year. Your program must consist of the following functions:
    a. FunctiongetData:Thisfunctionreadsandstoresdatainthetwodimensionalarray.
    b. FunctionaverageHigh:Thisfunctioncalculatesandreturnstheaveragehightemperaturefortheyear.
    c. FunctionaverageHigh:Thisfunctioncalculatesandreturnstheaveragelowtemperaturefortheyear.
    d. FunctionindexHighTemp:Thisfunctionreturnstheindexofthehighesthightemperatureinthearray.
    e. FunctionindexLowTemp:thisfunctionreturnstheindexofthelowestlowtemperatureinthearray.(These functions must all have the appropriate parameters.)

i have made this program and i think its useles....

i am just a newbie....

#include<iostream.h>
#include<conio.h>
void getData();
void averageHigh();
int main()
{
clrscr();
getData();
getch();
return 0;
}



void getData()
{
int total;
int x,y,ht,lt;
const a=12,b=2;
int array[a][b];
{
    for(x=1;x<=12;x++)
 {
    cout<<"Month :"<<x<<endl;
    for(y=0;y<1;y++)
    {
      cout<<"Enter Highest Temperature: ";
      cin>>ht;
      }
        cout<<"Enter Lowest Temperature: ";
      cin>>lt;
 }
    }
        array[ht][lt];
            total=array[ht][lt];
    cout<<total;

}

sori for bad writting style.....

Recommended Answers

All 5 Replies

There are many Mistakes in your Program.

Some of them i have found. But i will not post the total code for you i will only point the mistakes and you should solve them on your own.

So here Goes:

1)In your Program You are using functions like "cout<<" and "endl" but have not used the Namespace that holds all these functions .

I mean you need to add

using namespace std;

Into Your Code.

And After that.

Positioning of the Code Blocks. Just go to the code and try to analyse what you have programmed it to do.

Some things like Whether you have given the variables values before printing them out Should Be Checked.

Also The Usage of "{" and "}" Please check them too.

can you give me the overall format for the program???

just a summary..

i dont really know how to use array function...

i am using Borland C++

I prefer That you try to understand how the functions blocks are working and try to sort them out appropriately. And Try To Make Improvements.

Best of luck

commented: It was really necessary to hijack a 4 year old thread only to wish good luck to the person who posted, knowing that the thread is 4 years old. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.