100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
ENGR 103 Midterm Exam Questions With Correct Answers $11.49   Add to cart

Exam (elaborations)

ENGR 103 Midterm Exam Questions With Correct Answers

 5 views  0 purchase
  • Course
  • Engr 103
  • Institution
  • Engr 103

©SIRJOEL EXAM SOLUTIONS 12/3/2024 11:27AM ENGR 103 Midterm Exam Questions With Correct Answers (3 pts) What is the output of the following code, and why? int a = 1, b = 1, c = 1; if (a == b || c++){ int a = 20; b = b + a; } cout << a << " " << b << " " << c ...

[Show more]

Preview 4 out of 35  pages

  • October 16, 2024
  • 35
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Engr 103
  • Engr 103
avatar-seller
sirjoel
©SIRJOEL EXAM SOLUTIONS
12/3/2024 11:27AM



ENGR 103 Midterm Exam Questions With
Correct Answers


(3 pts) What is the output of the following code, and why?

int a = 1, b = 1, c = 1;

if (a == b || c++){

int a = 20;

b = b + a;

}


cout << a << " " << b << " " << c << " " << endl; - answer✔1 21 1 Hint: scope, short-circuiting


Algorithm - answer✔A methodical, logical rule or procedure that guarantees solving a particular

problem.


Computation - answer✔Operates to give an output that follows a definite set of rules.


Signed vs Unsigned - answer✔Signed can be negative and positive. Unsigned cannot be

negative.


Variable - answer✔Store value that can change depending on the condition

, ©SIRJOEL EXAM SOLUTIONS
12/3/2024 11:27AM


Operand vs Operator - answer✔The operator indicates what action or operation to perform.

Operands suggest what items to apply the action.


rvalue to. lvalue * pre and post-increment/decrement - answer✔lvalue is object and rvalue is

value.


% - answer✔operator use to get remain


What is the value of my_value in the following exmaple? int my_value; - answer✔any number


What are two ways to create a constant in C++ Wht are the pros and cons? - answer✔const int

my_constant= 42;

#define MY_CONSTANT 42

Given N bytes, what is the maximum and minumum represntable njmber of signed and

unsigned? - answer✔INT_MAX


INT_MIN




max = 65535

min -32768

, ©SIRJOEL EXAM SOLUTIONS
12/3/2024 11:27AM


Describe the diffence between syntax vs semantics - answer✔Syntax is concerned with the form

of the code, while Semantics is concerned with its meaning and behavior. Both are imporatn for

writting correct and effective C++ code.

List and label the relational and logical operators, and what is the difference between them? -

answer✔Relational operators are used to compare two value and determine the relationship

between them. They return Boolean value of either 'true' or 'false'

Like

< (less than)

> (greater than)

<= (less than or equal to)

>= (greater than or equal to)

== (equal to)

!= (not equal to)




Logical operators are used to perform Boolean operations on Boolean values.




&& (logical AND)

, ©SIRJOEL EXAM SOLUTIONS
12/3/2024 11:27AM


|| (logical OR)

! (logical NOT)


Give examples of when you use logical and relational operators in your every life - answer✔It is

sunny outside and I want to go to the beach.


What is short circuiting and when is it useful? - answer✔%% which stand for "AND" and ||

Which stand for "OR"


When would you use an if versus switch - answer✔If statement is when you want to test one or

more conditions and execute diferencet staments based on the results of the test.




Swtich in other hand is you when you want to choose betwen sveral alternative actions besed on

the vlaue of a single expression.


What are the limitations with a switch? - answer✔Limited data types like int char short or long




No expression




No range

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller sirjoel. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $11.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

72042 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$11.49
  • (0)
  Add to cart