[Solved] COMP1400 Assignment 3

$25

File Name: COMP1400_Assignment_3.zip
File Size: 197.82 KB

SKU: [Solved] COMP1400 Assignment 3 Category: Tag:
5/5 - (1 vote)
  1. 8 (p. 94) The following if statement is unnecessarily complicated. Simplify it as much as possible.

(Hint: The entire statement can be replaced by a single assignment.) if (age >=13)

if (age <=19)

teenage = true

else

teenage = false

else if (age < 13)

teenage = false

  1. 11 (p. 97) Write a program that asks the user for a two-digit number, and then prints the English word for the number:

Enter a two-digit number: 45 you entered the number forty-five.

Hint: Break the number into two digits. Use one switch statement to print the word for the first digit (twenty, thirty, and so forth). Use a second switch statement to print the word for the second digit. Dont forget that the numbers between 11 and 19 require special treatment.

  1. 1-3 (p. 121) What output does each of the following program fragment produce?

(a) i = 1; (b) i = 9384; (c) i = 5; while (i <= 128) { do { j = i 1;

printf(%d , i); printf(%d , i); for (; i > 0, j > 0; i, j = i-1) i *= 2; i /= 10; printf(%d , i);

} } while (i > 0);

  1. What output does each of the following flowcharts produce? Write a program fragment in C for each

of the flowcharts, and submit the codes online. of the flowcharts, and submit the codes online.

  1. 11 (p. 124) The value of the mathematical constant can be expressed as an infinite series:

Write a program that approximate by computing the value of

where n is an integer entered by the user. Save and submit the program as a3 epsilon0.c.

  1. 12 (p. 124) The attached flowchart a3 epsilon.rap provides a modified solution to Q3.5. It allows for continuous addition of terms until the current term becomes less than a small (floating-point) number entered by the user. Write an equivalent program in C, and save and submit the program as a3 epsilon1.c.

(Hint: In implementation, be careful with different types between the two sides of an assignment statement.)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP1400 Assignment 3
$25