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

👇 🌐 Top 10 Hosting for Developers in 2025: Fast, Reliable & Affordable

 Whether you’re a beginner building your first portfolio site or a professional developer deploying client projects, choosing the right host...