Please I want to write a sample program that will demonstrate different scope of variable | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Please I want to write a sample program that will demonstrate different scope of variable

Explain how the program will be executed by the computer

13th Jan 2017, 3:45 PM
Samuel
6 Réponses
+ 2
try this 1. define global variable a=100. 2. define local variable a= 50 in main 3. use same variable name in another function outside main a= 10 4. print all those with and without scope resolution operator ::
13th Jan 2017, 7:41 PM
Dipak Chauhan
Dipak Chauhan - avatar
+ 1
int a=200; void display(int a){ a = 10; cout << a << ::a; } main(){ int a = 50; void display(a); cout << a <<::a; } output 10 200 50 200
14th Jan 2017, 12:09 PM
Dipak Chauhan
Dipak Chauhan - avatar
0
Please how do I go about it Can u please write the code for me Pls
13th Jan 2017, 8:20 PM
Samuel
0
Pls I need the program
14th Jan 2017, 9:46 AM
Samuel
0
Thanks so much Mr dipak for the answer
15th Jan 2017, 6:27 AM
Samuel
0
The program is not running, it flag error Please can u help me out with the full code
15th Jan 2017, 6:36 AM
Samuel