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

DBMS NOTES UNIT 3

                                                              UNIT 3  ER (Entity Relationship) An entity-relationship model is known as an E...