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. What type of port numbers do servers use for common server programs? 18a.) On a server, well-known port numbers indicate _______. a. Applications b. Connections with client computers c. Both A and...
-
Generate a CART decision tree.
-
D. J. Harris checkbook lists the following: The January bank statement shows Requirement Prepare Harris bank reconciliation at January31. Date Check No. Item Check Deposit Balance $ 530 515 630 585...
-
Jammers Company produces one product that is sold for $52 per unit. Variable costs are $33.80 per unit and total fixed costs are $800,000. What is the dollar amount of sales revenue needed to achieve...
-
Transactions during 2020 follow: a. Borrowed $20,000 cash on July 1, 2020, signing a one-year, 10 percent note payable. b. Purchased equipment for $18,000 cash on July 1, 2020. c. Sold 10,000...
-
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...
-
In Question 9, would it make any difference if Schwartzs bank had confirmed the letter of credit and paid the promissory note before Rousseau learned of the supposedly defective shipment? nju5
-
460 V rms 3 phase full wave controlled rectifier feeds an inductive load. The supply voltage has a frequency of 50 Hz. If thyristors are considered ideal; a) Draw the voltage on the load when a = 25....
-
The following data is provided for Garcon Company and Pepper Company for the year ended December 31. Garcon Company Pepper Company Finished goods inventory, beginning $14,000 $17,950 Work in process...
-
On September 22, 2024, a flood destroyed the entire merchandise inventory on hand in a warehouse owned by the Rocklin Sporting Goods Company. The following information is available from the records...
-
A wound DC motor is connected in both a shunt and a series configuration. Assume generic resistance and inductance parameters Ra, Rf, La, Lf, let the field magnetization constant be kf and the...
-
Supermart Food Stores (SFS) has experienced net operating losses in its frozen food products line in the last few periods. Management believes that the store can improve its profitability if SFS...
-
For each function that is one-to-one, (a) write an equation for the inverse function, (b) graph and -1 on the same axes, and (c) give the domain and range of both f and -1 . If the function is not...
-
A company has the following incomplete production budget data for the first quarter: In the previous December, ending inventory was 200 units, which was the minimum required, at 10% of projected...
-
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.
-
THIS IS ONE QUESTION WITH TWO PARTS. PLEASE ANSWER COMPLETELY AND SHOW ALL WORK. (NO EXCEL) Information for Question 1: State Probability Retum on A Return on B Return on C Retum on Portfolio X Boom...
-
Direct materials (5.0 Ibs. @ $5.00 per Ib.) Direct labor (2.0 hrs. @ $13.00 per hr.) Overhead (2.0 hrs. @ $18.50 per hr.) Total standard cost $25.00 26.00 37.00 $88.00 The predetermined overhead rate...
-
Problem 1-28 (Algo) (LO 1-4, 1-5, 1-6b 1-7) Harper, Inc., acquires 40 percent of the outstanding voting stock of Kinman Company on January 1, 2020, for $316,100 in cash. The book value of Kinman's...
Study smarter with the SolutionInn App