1. Trang chủ
  2. » Tất cả

17-18,HK2_C Programming Language(CLC)Mau 3

5 1 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 157,99 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

1 HCMC University of Technology and Education Faculty for High Quality Training ECET Final exam of the semester 2, 2017-2018 Course: C Programming Language Course code: PRLA335164E N

Trang 1

1

HCMC University of Technology and Education

Faculty for High Quality Training

ECET

Final exam of the semester 2, 2017-2018 Course: C Programming Language Course code: PRLA335164E

Number of pages: 05 pages Duration: 90 minutes

Only used one A4-handwriting paper

Students work directly on the test and submit all

Supervisory Signature 1 Supervisory Signature 2

Points and Signatures

The first marking

lecturer

The second marking lecturer First and last name:

Student ID: Order number: Room:

Question 1 (2.0 points): Give a following program, please perform:

a) Draw a flowchart?

b) Show results on the screen after performing the program?

# #include <stdio.h>

int main (void)

{

int a = 10, b = 5, c = 17, d=2;

if ((a > b) && (b<c))

{

a = c + 2;

b += d - 2;

c = a / b;

d = ++b - c;

}

else

{

b -= ++a;

d = c - b;

}

printf("a:%d\n", a);

printf("b:%d\n", b);

printf("c:%d\n", c);

printf("d:%d\n", d);

return 0;

}

a) a flowchart

b) Results on the screen

………

………

Trang 2

2

Question 2 (2.0 points): Draw flowchart and write a program that sums a sequence of integers

Assume that the first integer read with scanf specifies the number of values remaining to be entered Your program should read only one value each time scanf is executed For example, a typical input sequence might be 5 100 200 300 400 500 where the 5 indicates that the subsequent five values are

to be summed

Question 3 (1.5 points): Show results on the screen after performing a following program: # #include <stdio.h> void main() { int a[6] = { -2, 0, 2, 3, 4, 5 }; int *p1 = &a[1]; int *p2 = &a[2]; *(p1 - 1) = *p2 + 2; *p1 = *p2 - 4; *(p2 + 1) = a[4] + a[5]; p2++; *(p2 - 1) = *(p1 - 1) + *p1 + 1; *(p2 + 1) = *p1 + 2; *(p2 + 2) = 2 * *p1 + 5; printf("%d, %d, %d, %d, %d, %d", a[0], a[1], a[2], a[3], a[4], a[5]); }

Results on the screen ………

………

………

………

………

………

………

………

………

………

………

Trang 3

3

Question 4 (3.0 points):

- Edit bugs of a following program (2.0 points):

The program

#include <stdio.h>

#include <conio.h>

#include <malloc.h>

void Function1(int *x, int y)

int Function2(int *x, int y)

int Function3(int *x, int y);

void main()

{

int *array, n, i;

scanf("%d", &n);

array = (int *)malloc(n,sizeof(int));

if (array != NULL)

{

Function1(array, n)

if (Function3(array, n) == 1)

if (Function2(array, n) == 1)

for (i = 0; i < n; i++)

if (*(array + i) % 2 == 1)

printf(" %d ", *(array + i));

}

}

void Function1(int *x, int y)

{

int i;

for (i = 0; i < y; i++)

scanf("%d", *(x + i));

}

int Function2(int x, int y)

{

int i;

for (i = 0; i < y, i++)

{

if (*(x + i) % 2 == 1)

return 1;

}

return 0;

Edit bugs

Trang 4

4

}

int Function3(int *x, int y)

{

int i;

for (i = 0; i < y - 1; i++)

{

if (*(x + i) > (x + i + 1))

return 0;

}

return 1;

}

- Assume that the above program is edited correctly When five numbers 4, 5, 6, 7, 8 are inputted from the screen, what are results showed on the screen next (1.0 point)?

Question 5: (1.5 points) Write a complete program which executes functions as follows: a) Create a structure type, named SensorNode, to describe a Sensor Node The Sensor Node will collect temperatures and includes information as follows:  Node Code (named NodeCode): string format  Temperature value (named Temp): real number format b) Enter information including Node Code and Temperature value of 20 different Sensor Nodes c) Print all information of three Sensor Nodes on the screens which collect high temperature values 1st, 2nd and 3rd

Trang 5

5

Notation: Supervisor officials are not allowed to explain the exam questions

[G1.1, G1.3]: Draw a flowchart, demonstrate command syntax,

operation and application of branching and iteration structures in C

language

Questions 1, 2

[G1.5]: Present how the pointer is declared and how to use the pointer

to retrieve the memory

Questions 3, 4

[G1.7]: Define structure type and use structure variables to store and

manage data

Question 5

[G2.1]: Analyze the programming requirements from which to build a

flowchart, a complete program

Questions 1, 2, 5

[G3.1]: Apply control structures, apply data manipulation, build support

functions to design and solve application programming requirements

Questions 2, 5

May 23th, 2018

Head of ECET

Ngày đăng: 16/06/2021, 18:17

🧩 Sản phẩm bạn có thể quan tâm