Question

Question Five c++ Decision Structures and Boolean Logic 1. Write an if statement that assigns 20...

Question Five

c++

Decision Structures and Boolean Logic

1. Write an if statement that assigns 20 to the variable y and assigns 40 to the variable z if the variable x is greater than 100.

2. Write an if statement that assigns 0 to the variable b and assigns 1 to the variable c if the variable a is less than 10.

3. Write an if-else statement that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1). if(x>100){

y=20;

z=40;

}

2). if (a<10){

c=1;

b=0;

}

3). if (a<10)

{

b=0;

}

else

{

b=99;

}

Add a comment
Answer #2

1). if(x>100){

y=20;

z=40;

}

2). if (a<10){

c=1;

b=0;

}

3). if (a<10)

{

b=0;

}

else

{

b=99;

}

Add a comment
Know the answer?
Add Answer to:
Question Five c++ Decision Structures and Boolean Logic 1. Write an if statement that assigns 20...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement...

    EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement that multiplies payRate by 1.5 iſ hours is greater than 40. Write variable declarations for the variables payRate and hours first. Hint: Look for keyword if first, your boolean comes after the keyword [. This translates into Java as: double hours, payRate; if (hours > 40) { //{-} are optional here but I recommend that you them payRate = payRate 1.5; pay Rato pay...

  • I need to run each questions also with the outputs print 1. 3.1 Write an if...

    I need to run each questions also with the outputs print 1. 3.1 Write an if statement that assigns 0 to x when y is equal to 20. If (y == 20) X=0; 2. 3.2 Write an if statement that multiplies payRate by 1.5 if hours is greater than 40. If (hours > 40) payRate - payRate * 1.5; 3. 3.12 Write nested if statements that perform the following test: If amounti is greater than 10 and amount 2 is...

  • This is Visual Basics... Write an if/else statement that assigns true to the variable fever if...

    This is Visual Basics... Write an if/else statement that assigns true to the variable fever if the variable temperature is greater than 98.6; otherwise it assigns false to fever.* Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 through 64 and adds 1 to the variable seniors if age is 65 or older.*

  • Small aircraft weight limit Write an if-else statement that assigns safetyCheck with 1 if the sum...

    Small aircraft weight limit Write an if-else statement that assigns safetyCheck with 1 if the sum of passengerWeight and cargoWeight is less than or equal maxWeight. Otherwise, assign safetyCheck with 0. Ex: If passengerWeight is 200, cargoWeight is 100, and maxWeight is 500, then safetyCheck is assigned with 1. If passengerWeight is 300, cargoWeight is 275, and maxWeight is 500, then safetyCheck is assigned with 0. Function Save C Reset DI MATLAB Documentation 1 function safetyCheck = CargoLimit(passengerWeight, cargoweight) 2...

  • Programming question. Using Visual Studio 2019 C#. Windows Forms Application. Write the code that assigns the...

    Programming question. Using Visual Studio 2019 C#. Windows Forms Application. Write the code that assigns the number 15 to the reward variable when the state variable contains the string “IL” (entered using any case) and the sales variable contains a number that is greater than 2000; otherwise, assign the number 5.

  • Python Activity 05 Boolean Expressions - POGIL (5) - Word Search m Layout References Mailings Review...

    Python Activity 05 Boolean Expressions - POGIL (5) - Word Search m Layout References Mailings Review View Help Critical Thinking Questions Programming Structures Sequence Structure Decision or Branching Structure Looping Structure FALSE Which structure best describes the types of Python programs you have written so far? _sequence structure Which structure allows the programmer to create code that decides what code is executed? FYI: Conditional operators, also known as relational operators, are used to compare the relationship between two operands. Expressions...

  • 1. (15 pts) Simplify the following Boolean functions using K-maps: a. F(x,y,z) = (1,4,5,6,7) b. F(x,...

    1. (15 pts) Simplify the following Boolean functions using K-maps: a. F(x,y,z) = (1,4,5,6,7) b. F(x, y, z) = (xy + xyz + xyz c. F(A,B,C,D) = 20,2,4,5,6,7,8,10,13,15) d. F(A,B,C,D) = A'B'C'D' + AB'C + B'CD' + ABCD' + BC'D e. F(A,B,C,D,E) = (0,1,4,5,16,17,21,25,29) 2. (12 pts) Consider the combinational logic circuit below and answer the following: a. Derive the Boolean expressions for Fi and F2 as functions of A, B, C, and D. b. List the complete truth table...

  • Question 1 Digital Electronics and Combinational Logic 1a) Analog and Digital Electronics i. Write either "digital"...

    Question 1 Digital Electronics and Combinational Logic 1a) Analog and Digital Electronics i. Write either "digital" or "analog" in this to indicate whether the property in that row is - typical of digital electronics or analog electronics. The first row has been completed as an example. Property Digital/Analog Difficult, manual circuit design Analog Continuous valued signals Tolerant of electrical noise Circuit state tends to leak Intolerant of component variations ii. In older cars the timing of the electrical pulses to...

  • IN C++ Programming : Continue to write an if statement that assigns 8.75 to dvar2 when...

    IN C++ Programming : Continue to write an if statement that assigns 8.75 to dvar2 when dvar1 is less than 8.99 Suppose we have the following lines of the code: Int main() { double dvar1, dvar2; cout << “Enter a decimal number: “; cin >> dvar1; //add more lines of the code below return 0; }

  • 2. Design a combinational logic circuit with three inputs x, y, and z, and three outputs...

    2. Design a combinational logic circuit with three inputs x, y, and z, and three outputs A, B, and C. When the binary input value is 0, 1, 2, or 3, the binary output value is 2 greater than the input, i.e. (ABC) = (xyz) + 2. Otherwise, the binary output value is 3 less than the input, i.e. (ABC) = (xyz) – 3.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT