1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Bài tập Kỹ thuật vi xử lý - DTVT - BKDN (bài08)

2 12 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Bài tập Kỹ thuật vi xử lý - DTVT - BKDN

Homework #8 Types, Operators, and Expression (Ch 13) and Control Flow (Ch 14) In order to automate the grading process, please follow the exact instructions for each questions and don’t use extra or unnecessary words (11 points) If a=6 and b=9 for each of the given expressions, what are the values of a and b and the result of the expression after each statement is executed? Expression 10 11 a a a a a a a a a a a a b Result | b || b % b %= b = b = b = 2) printf ( "True" ); else printf ( "False" ); (2 points) Does the following code cause an infinite loop? Why or why not? Hint: How does overflow affect the condition statement? Use Code Composer Essentials to test this code int x = 1; while (x > 0) x++; BYU, ECEn/CS 124 Homework #8 (4 points) For the following statements: int x , y; switch (x) { case : y = 1; case : y = 3; break; default : y = 7; break; } //end switch a) What value will y have when x = 0? b) What value will y have when x = 1? (4 points) Suppose a program contains the two variables x and y a) First, write a routine (three lines) to exchange x and y using a temporary variable for storage b) Rewrite this routine (three lines) to exchange x and y WITHOUT using a temporary variable (3 points) What does this code print? Write all numbers printed in one line with a space between prints for (i=0; i 5) break; if (i > 1) continue; printf(“%d ”, i); } Answer: BYU, ECEn/CS 124 Homework #8

Ngày đăng: 06/09/2021, 17:29

Xem thêm:

TỪ KHÓA LIÊN QUAN

w