首页 > > 详细

ELEE08022程序设计讲解、辅导C++程序、Software程序留学生辅导 讲解Processing|辅导留学生 Statistics统计、回归、迭代

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
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}

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!