(C++)Can I use the same identifie for the return variable of a function and the variable in the main program where it's stored? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

(C++)Can I use the same identifie for the return variable of a function and the variable in the main program where it's stored?

For example: int sum(int A, int B) { int SUM; SUM=A+B: return SUM; } main() { int N1, N2, SUM; cin >> N1; cin >> N2; SUM = sum(N1, N2); cout << "\n" << sum << "\n"; system("pause"); } I used the "SUM" variable either in the function and in the main program, is it ok?

9th Dec 2017, 11:08 PM
Fatess
1 Answer
+ 11
yes
9th Dec 2017, 11:23 PM
Vukan
Vukan - avatar