DRIVING ME NUTS

back AGAIN idk why this is not working im doing this from watch a video step by step and some how it driving me nut and i know im missing 1 little thing but i cant find it if u have time mind helping me now in the erro prompt below it say number was not declared but it was in the 'Sqr' function just dont know and if i put 'Public int Sqr' it get worst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using namespace std;

int Sqr(int number){

    int squ = number * number;
    return squ;
}


int main(){

int num;

    cout << "Enter A Number : ";
    cin >> num;
    cout << endl;
    cout << num << " square = " << Sqr(number) << endl;

    return 0;
}


and the error code is:
||=== Build: Debug in TheWorld2 (compiler: GNU GCC Compiler) ===|
C:\Users\Michael\Desktop\TheWorld2\main.cpp||In function 'int main()':|
C:\Users\Michael\Desktop\TheWorld2\main.cpp|22|error: 'number' was not declared in this scope|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Last edited on
just replace Sqr(number) with Sqr(num) and you are good to go....

SEE IT OLD YALL IT WOULD HAVE BEN SOME THING SIMPLE ty mate
welcome mate.... :D
Topic archived. No new replies allowed.