100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

ENGR 103 Midterm Exam Questions With Correct Answers

Rating
-
Sold
-
Pages
35
Grade
A+
Uploaded on
16-10-2024
Written in
2024/2025

©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; - answer1 21 1 Hint: scope, short-circuiting Algorithm - answerA methodical, logical rule or procedure that guarantees solving a particular problem. Computation - answerOperates to give an output that follows a definite set of rules. Signed vs Unsigned - answerSigned can be negative and positive. Unsigned cannot be negative. Variable - answerStore value that can change depending on the condition ©SIRJOEL EXAM SOLUTIONS 12/3/2024 11:27AM Operand vs Operator - answerThe operator indicates what action or operation to perform. Operands suggest what items to apply the action. rvalue to. lvalue * pre and post-increment/decrement - answerlvalue is object and rvalue is value. % - answeroperator use to get remain What is the value of my_value in the following exmaple? int my_value; - answerany number What are two ways to create a constant in C++ Wht are the pros and cons? - answerconst int my_constant= 42; #define MY_CONSTANT 42 Given N bytes, what is the maximum and minumum represntable njmber of signed and unsigned? - answerINT_MAX INT_MIN max = 65535 min -32768 ©SIRJOEL EXAM SOLUTIONS 12/3/2024 11:27AM Describe the diffence between syntax vs semantics - answerSyntax 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? - answerRelational 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)

Show more Read less
Institution
Engr 103
Module
Engr 103











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Engr 103
Module
Engr 103

Document information

Uploaded on
October 16, 2024
Number of pages
35
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

©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

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
sirjoel Liberty University
View profile
Follow You need to be logged in order to follow users or courses
Sold
109
Member since
1 year
Number of followers
13
Documents
11865
Last sold
3 days ago
Sirjoel

Here you will find all documents and package deals offered by sirjoel

3.5

17 reviews

5
4
4
4
3
7
2
1
1
1

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions