Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need assistance with #1 through #10. Will rate positively if FULLY completed. Th

ID: 2246385 • Letter: N

Question

Need assistance with #1 through #10. Will rate positively if FULLY completed.

The C++ preprocessor directive #include is most like which C preprocessor directive? Why is each #include included? What is the purpose for this using directive? using namespace std: Translate each of the following C statements into its C++ equivalent. Assume using namespace std: is coded in the program so you are not required to scope-resolve references to the stream variables cin and cout. Describe/Define each of the 3 tokens used to code the scope-resolved reference the stream variable cout, namely, std:: cout. std:: cout Make the following 2-line sentences into C++ comments using appropriate C++ comment-building syntax. Make these 2 lines a single 2-line C++ comment. Make these 2 lines 2 1-line C++ comments. Evaluate the bool expression (true || false && false || ! false)

Explanation / Answer

1. C++ : #include<iostream> is equivalent to #include<stdio.h> in C
Explanation : iostream is nothing but input/output stream i.e streams of input and output
where as in C its standard input output

2. The purpose of using directive means that we are going to use it, hence we write using .
And to use what ? So we are going to use namespace
Which namespace ? std namespace.
In std namespace all the features of C++ standard library is present. Like cout, cin, stack , queue, vector etc
If we declare using namespace std in our program
Instead of writing std::cout , we can directly use cout because namespace std is already included in our program.


3. int x, y; //Declaration is same in C and C++

4. cout<<x <<y << ;

5. cin >>x >>y;

6. x -= y+2 //Same in C and C++

7. Its exactly same as given in C code :
Reason: if is present in C++ , %, +, == everything used in snippet is also present in C++

8. std
is the namespace name


:: -> It is the scope resolution operator which is used to access global variables as well and to include cout, vector etc.
If we do not specify namespace in our program then we need help of scope resoltion to use that otherwise compiler might not understand. So std::cout , std::vector, std::stack is used with help of scope resolution


cout : Its the output stream used in C++ to print the output to console

9. /* Make these two line a single 2 line
              C++ comment    */
//    Make these two line a 2 1-line C++ comments

Explanation:

/* Multiline comment */

// Single line comment

1
0. ! has more priority than || and && so its evaluated first
     && has more priority than || so its evaluated first

(true || false && false || !false)
=> (true || false && false || true)
=> (true || false && false || true)

=>(true || false || true)
=>(true || true)
=> true

So the boolean expression evaluated to true.

Thanks, let me know if there is any concern. I hope its clear if not please comment. I will surely respond.




Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote