ECE175 | ECE 175: Computer Programming for Engineering Applications Lab 3

ECE 175: Computer Programming for Engineering Applications Lab 3

联系我们: 手动添加方式: 微信>添加朋友>企业微信联系人>13262280223 或者 QQ: 1483266981

ECE 175: Computer Programming for Engineering Applications

Lab 3

Topics: nested loop and File I/O

Demo to TA or ULA your code for each problem by the end of your lab session in order to earn your lab 3 score.

Problem 1 (15 points):

Write a C program that lets a user enter only a number between 1 and 9 and display the following output pattern. Your program should make sure that a user enters only a positive number between 1 and 9.

Hint: Nested loops should be used.

Note: Your code must work for any user input from 1-9. If you hard-code the pattern in your program, you will get 0 point for this problem.

Sample code execution 1: Bold text indicates information entered by a user Enter only integer 1-9: -5

Enter only integer 1-9: 0

Enter only integer 1-9: 12

Enter only integer 1-9: 4

1

222

33333

4444444

From the output pattern above,

first row, 3 spaces then 1 digit of 1 is displayed second row, 2 spaces then 3 digits of 2 are displayed third row, 1 space then 5 digits of 3 are displayed fourth row, 0 space then 7 digits of 4 are displayed

Sample code execution 2: Bold text indicates information entered by a user Enter only integer 1-9: 9

1

222

33333

4444444

555555555

66666666666

7777777777777

888888888888888

99999999999999999

Problem 2 (15 points):

发表评论

了解 KJESSAY历史案例 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读