What will the following program display? #include using namespace std; void other(); namespace n1 { int x
Question:
What will the following program display?
#include
using namespace std;
void other();
namespace n1
{
int x = 1;
}
namespace n2
{
int x = 2;
}
int main()
{
using namespace n1;
cout << x << endl;
{
int x = 4;
cout << x << ", " << n1::x << ", " << n2::x << endl;
}
using n2::x;
cout << x << endl;
other();
return 0;
}
void other()
{
using namespace n2;
cout << x << endl;
{
int x = 4;
cout << x << ", " << n1::x << ", " << n2::x << endl;
}
using n2::x;
cout << x << endl;
}
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 73% (15 reviews)
The program will display 2 2 4 2 2 4 The other function is written in the namespace n2 and hence has ...View the full answer
Answered By
James Warinda
Hi! I’m James Otieno and I'm an experienced professional online tutor with countless hours of success in tutoring many subjects in different disciplines. Specifically, I have handled general management and general business as a tutor in Chegg, Help in Homework and Trans tutor accounts.
I believe that my experience has made me the perfect tutor for students of all ages, so I'm confident I can help you too with finding the solution to your problems. In addition, my approach is compatible with most educational methods and philosophies which means it will be easy for you to find a way in which we can work on things together. In addition, my long experience in the educational field has allowed me to develop a unique approach that is both productive and enjoyable.
I have tutored in course hero for quite some time and was among the top tutors awarded having high helpful rates and reviews. In addition, I have also been lucky enough to be nominated a finalist for the 2nd annual course hero award and the best tutor of the month in may 2022.
I will make sure that any student of yours will have an amazing time at learning with me, because I really care about helping people achieve their goals so if you don't have any worries or concerns whatsoever you should place your trust on me and let me help you get every single thing that you're looking for and more.
In my experience, I have observed that students tend to reach their potential in academics very easily when they are tutored by someone who is extremely dedicated to their academic career not just as a businessman but as a human being in general.
I have successfully tutored many students from different grades and from all sorts of backgrounds, so I'm confident I can help anyone find the solution to their problems and achieve
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
A study of job satisfaction was conducted for four occupations: cabinetmaker, lawyer, physical therapist, and systems analyst. Job satisfaction was measured on a scale of 0 00. The data obtained are...
-
What will the following program segments display? a) for (int count = 0; count < 6; count++) System.out.println(count + count); b) for (int value = -5; value < 5; value++) System.out.println(value);...
-
What will the following two-file program display? // file1.cpp #include using namespace std; void other(); void another(); int x = 10; int y; int main() { cout < < x < < endl; { int x = 4; cout < < x...
-
Calculate the IRR for the following projects. a. An initial outflow of $15,220 followed by inflows of $5,000, $6,000, and $6,500. b. An initial outflow of $47,104 followed by inflows of $16,000,...
-
In general, what would be the likely effect of the following occurrences on the money and capital markets? a. The savings rate of individuals in the country declines. b. Individuals increase their...
-
A survey of U.S. adults ages 21 and older who are regular drinkers found that 38% name beer as their favorite beverage. You randomly select 25 U.S. adults ages 21 and older who are regular drinkers...
-
1. Identify 3 students to play the roles of the employees. Ask these 3 individuals to read their roles below. 2. Identify 1 student to play the role of the president of the social enterprise (Taylor...
-
The graph in Figure represents various flows that can occur through a sewage treatment plant with the numbers on the arcs representing the maximum flow (in tons of sewage per hour) that can be...
-
Provide a clear definition of SES (Socioeconomic Status), encompassing its components such as income, education, and occupation. Discuss the societal implications of SES and its role in shaping...
-
Locate the center of gravity of the sheet-metal form shown. T1.8 m 1.2 m 0.5 mi 1.5 m
-
Provide method definitions for the class described in Chapter Review Question 5 and write a short program that illustrates all the features. Data From Question 5 Define a class to represent a bank...
-
Suppose you want the average(3,6) function to return an int average of the two int arguments when it is called in one file, and you want it to return a double average of the two int arguments when it...
-
What is the difference between map scale and resolution? Using your town and state or province, distinguish between large-scale and small-scale maps.
-
According to the Adams v. Krueger case in our textbook, the doctor's nurse practitioner (NP) diagnosed plaintiff with genital herpes when, in fact, she had a yeast infection. The doctor failed to...
-
Darla has an annual income of $120 that she spends on movies, at $10 per show, and All Other Goods. Suppose a movie theatre offers to sell her a pass that will allow her to see any amount of movies...
-
Writ the C++ code of queue which is performed multiple task which are given below and performed all task by using Arrays. I.En-queue values 10, 20, 5 , 50, 40, 60, 45 II.De-queue values 45, 60, and...
-
Fire Roasted primarily used a specialty blend, Saint Drogo, for its classic drip coffee. Saint Drogo was made with 40 per cent Brazilian beans, 30 per cent Peruvian beans, and 30 per cent Costa Rican...
-
You have just graduated from college. In school, you and your classmates planned to put up an anti-aging cosmetic business, to put into actual practice what you have learned in the business school. ...
-
Helium undergoes a Stirling refrigeration cycle, which is a reverse Stirling power cycle. At the beginning of isothermal compression helium is at 100 kPa, 275 K. The compression ratio is 4 and during...
-
Pedro Bourbone is the founder and owner of a highly successful small business and, over the past several years, has accumulated a significant amount of personal wealth. His portfolio of stocks and...
-
What is the output from the following code segment? int[] [] intArray = {{2, 5, 4), (6, 3), (9, 7, 1, 5}}; (intArray [0].length); (int Array [2]. length); System.out.println System.out.println...
-
What is the output from the following code segment? double [] [] grades; grades = new double [34] [15]; System.out.println (grades [11] .length); System.out.println (grades [34].length) ;...
-
Using the array intArray described in the previous exercise, write a code segment to output all the even numbers in the array, regardless of their position in the array.
-
Assuming constant specific heat and First law: - w = ph-Rh = PH2 14.46 kJ/kgK == CpN2 1.043 kJ/kgK, PH20 == 2.607 kJ/kgK, == Cpo2 0.972 kJ/kgK h =-241,820 kJ/kmol H20.vapor h =-285,830 kJ/kmol...
-
Problem 2 Consider the hydraulic tank system with inertance and hose compliance shown below. P P= hose h R: grove A P = 0 The hose has length L, cross-sectional area a, and its compliance is...
-
Address one of the following, and include which one you are discussing at the top of your post: Age: There is controversy around the speculation/confirmation of the number of airline pilots available...
Study smarter with the SolutionInn App