Prepare
Practice
Interview
Aptitude
Reasoning
English
GD
Placement papers
HR
Current affairs
Engineering
MCA
MBA
Online test
Login
Online Practice Test
>
CPP 3
« Previous
Next »
int a = 10;
void main()
{
int a = 20;
cout << a << ::a;
}
The output of this program is
Options
- Syntax error
- 10 20
- 20 10
- 20 20
CORRECT ANSWER : 20 10
Discussion Board
Commenting
Very nicely done.!!!
Dikshita 03-18-2023 02:51 PM
Correct code
#include
using namespace std;
int a = 10;
int main()
{
int a = 20;
cout << a <<" " <<::a;
return 0;
}
jjasdf 05-3-2019 06:01 PM
C++ - Trace the Output
The above program can have same name for local and global variables but value of local variable inside a function will take preference. When the above code is compiled and executed, it produces the following result:
2010
Prajakta Pandit 01-25-2017 04:06 AM
No
The output will be
2010
sdp 05-4-2015 07:03 AM
« Previous
Next »
Write your comments
*
*
Email must be in the form someone@domain.com
*
*
Enter the code shown above:
Please enter the code shown above
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
Related Content
C test (42)
C (12)
C++ for beginners (10)
C++ (20)
C++ (24)
C++ (18)
C++ (14)
C++ (12)
C++ (15)
C++ (15)
Data structure (20)
Data structure (10)
Data structure (10)
Data structure (10)
PERL (25)
VC++ (11)
Oops (30)
Mainframe (41)
Mainframe (15)
Embedded systems (15)
OOAD (49)
Advertisement
▲