- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsameVarName.cpp
More file actions
Latest commit
28 lines (21 loc) · 607 Bytes
/
Copy pathsameVarName.cpp
File metadata and controls
28 lines (21 loc) · 607 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream>
#include<string>
usingnamespacestd;
doublesqr(double x)
{
double number;
number = x*x;
return number;
}
intmain()
{
double number, squareNumber;
cout << "input a number : ";
cin >> number;
squareNumber = sqr(number); //we use the function here
cout << "The square value of " << number << " is " << squareNumber << endl;
return0;
}
/* In this example, we can see there is a same name for two variables
it don't make conflict because the two var are in != functions */
/* If they was in the main function, it could not have been possible */