联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2021-02-02 11:28

Software and Embedded System Lab 2 (ELEE08022)

Data Type & Organisation in C language

1. All programs contain bugs, some more serious than others (the bugs, not the programs). Identify and

correct three errors in the following program. (hint: the first most serious error is that the program is

poorly commented, perhaps because the program as a whole wasn’t properly thought out before it was

coded in the C language, hence producing the second most serious error.)

/* Calculate the area of an ellipse in sq cm */

#include <stdio.h>

int main(void)

{

float area, major_axis, minor_axis;

area = 3.1416 * major_axis * minor_axis;

minor_axis = 6.4;

major_axis = 2.7;

printf("Area of ellipse is %f sq. cm\n", area);

}

2. Write a C program to input eight integer numbers into an array named amps. After all the numbers

have been input, display the numbers and calculate and display their average.

3. Write a program to read into an array named volts, the following values typed at the keyboard:

10.95, 16.32, 12.15, 8.22, 15.98, 26.22, 13.54, 6.45, 17.59. After all the

data have been read in, print out the values stored in the array in the following three row by three column

form:

10.95 16.32 12.15

8.22 15.98 26.22

13.54 6.45 17.59

4. Write a program to print the payment records of 5 employees. The record of each employee should

be constructed in a structure with three members. They are a long integer storing employee’s ID, a

character array storing employee’s name, and a float number storing hourly rate. The records of 5

employees should be initialised as:

{32479, “Abrams, B.”, 6.72}

{33623, “Bohm, P.”, 7.54}

{34145, “Donaldson, S.”, 5.56}

{35987, “Ernst, T.”, 5.43}

{36203, “Gwodz, K.”, 8.72}


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp