Tuesday, September 30, 2014

[Delivery] Struct

Bài 1: Write a C Program to store student data in a structure. The data should include student ID, name, course registered for, and year of joining. Write a function to display the details of students enrolled in a specified academic year. Write another function to locate and display the details of a student based on a specified student ID.



To do this,

a.       Define the structure to store the student details.

b.      Declare and initialize the structure with details of 10 students.

c.       Set a loop to display a menu for the operations to be performed.

d.      Accept the menu choice and invoke appropriate functions with the structure array as parameter.
e.       In the function to display students for a year, accept the year. Set a loop to check each student’s enrollment year, and display if it matches. At the end, allow the user to specify another year.
In the function to locate student details, accept the student ID. Set a loop to check each student’s ID, and display if it matches. At the end, allow the user to specify another student ID.

Code:

Thursday, September 25, 2014

[Delivery] Pass by references

Bài 1: 1. Viết hàm truyền vào 2 số nguyên bất kỳ, thực hiện đổi chỗ 2 số đóNguyên mẫu hàm như sau: void swap (int &number1, int &number2);




My code + result

[Delivery] Pass by value

Bài 1: Write a function which accepts an integer value as input, and returns an integer which is the cube of that input



My code + result

Tuesday, September 23, 2014

Test


[Delivery] Exercise function

Bài 1: 1. Write a C program that accepts a number and square the number with the help of a function.


To do this,

a. Declare a function.

b. Accept the number.
c. Pass the number to the function and return the square of that number

Function prototype: int cal_square(int number);


My code + result

Monday, September 22, 2014

[Delivery] Character array

Bài 1: Write a program which prints the letters in a char array in reverse order. For example, if the array contains {'c', 's', 'c', '2', '6', '1'}the output (to the terminal) should be "162csc".


My code + result