Sunday, 3 February 2019

Write a program using Scope Resolution Operator

Program allowing access to global variables along with local variables of same name using  scope resolution operator. 



1. Write this code in any C++  software.


#include<iostream.h>

#include<conio.h>

 int x=10;  //GLOBAL VARIABLE

void main()

{

clrscr();
 int x= 30;//LOCAL VARIABLE

cout<<"\nValue of x in main is" <<x;

cout<<"\nValue of x Globally is" <<::x;
getch();

}

 2. Now compile the code and run .The output screen  will look like this :-



No comments:

Post a Comment

Java Unit Wise Notes

 JAVA Notes   --- UNIT-I DETAILED NOTES (JAVA) 1. History of Java Developed by James Gosling at Sun Microsystems (1991–1995). Initia...