C++ arrays its somethiing really simple i know ubt i cant

figure it out...


//glenda hayes
//lab 7

#include <iostream>

using namespace std;



int main()
{
const int OuterTemp=20;
const int InnerTemp=20;//this is for the Outside

int f;//row
int j;//column
int T;//Tempeture
int temp1;
int temp2;
for(f=0;f<OuterTemp;f++)
{
cout<<"Please enter in the tempeture.." <<endl;
cin>>temp1;
for(j=0;j<InnerTemp;j++)
{
cout<<"please enter in the tempeture.."<<endl;
cin>>temp2;


}
}
T[f][j]=1/4 (T [f-1] [j]+ T [f] [j-1] + T [f] [j+1] );
cout<<T;

system("pause");
return 0;
}
C:\Users\Glenda hayes\Documents\c++ programing labs\lab7.cpp: In function `int main()':
C:\Users\Glenda hayes\Documents\c++ programing labs\lab7.cpp:32: error: invalid types `int[int]' for array subscript
C:\Users\Glenda hayes\Documents\c++ programing labs\lab7.cpp:32: error: invalid types `int[int]' for array subscript
C:\Users\Glenda hayes\Documents\c++ programing labs\lab7.cpp:32: error: invalid types `int[int]' for array subscript
C:\Users\Glenda hayes\Documents\c++ programing labs\lab7.cpp:32: error: invalid types `int[int]' for array subscript
C:\Users\Glenda hayes\Documents\c++ programing labs\lab7.cpp `4' cannot be used as a function
Last edited on
T is not an array, it is just an int....
well then what would i do to make it an array.. because that is the formula that i was given
closed account (zb0S216C)
You need to declare T as an array. This is accomplished by doing the following: int T[N]. Here, N is the length of the array.

Wazzak
Last edited on
k i made it into an array.. but its still showing the same errors..

const int N=20;
const int OuterTemp=20;
const int InnerTemp=20;//this is for the Outside

int f;//row
int j;//column
int T[N];//Tempeture
int temp1;
int temp2;
for(f=0;f<OuterTemp;f++)
nvm now its just showing the last error. that 4 cannont be used as a function
It looks like you want some kind of operator between 4 and the parenthesis to the right?
it must be along day because i dont see what should be there
In C++ multiplication is not implicit like in math. I don't know if it is multiplication you want.

Also note that 1/4 will do integer division and give the value 0. If you meant 0.25 you better write it as "0.25". If you want to use division just make sure at least one of the operands are of floating point type if you want the result to be a floating point type.
Last edited on
well even if i type in 0.25 it still says the same thing.
changed one of the things to a float still having teh same problem do i need to put it in ()?
Did you use a * for multiplication?
no i haven't tried that yet... hmm
it worked thanks.. lol wow i can't belive i didnt' try that..
Topic archived. No new replies allowed.