**Elementary Programming With C Assignment**

**Question 1: [15]**

Write a menu-based program with the following menu: [1.5]

1.Input N,M.

2.Display rectangle number of M with N columns.

3.Calculate total of the prime numbers in this rectangle.

4.Calculate total of the numbers in the last col.

5.Exit.

**Q1. Input N [3.0]**

When user chooses 1 from main menu, do the followings:

- First, display “Enter the value of N:” and accept integer N which must be a positive number.
- Then, show warning message and reaccept N if user input a negative or zero number.
- Next, display “Enter the value of M:” and accept integer M which must be greater than N.
- Then, show warning message and reaccept M if it is less than N.
- Finally, store N, M into variables in main function and return to the main menu.

This module must be coded in a function which does the followings:

- Accept two arguments by reference (using pointer).
- Store value from user’s input into variable in main function.

**Q2. Display rectangle number of N [4.0]**

When user chooses 2 from main menu, display rectangle number of M with N columns (the rectangle which the first position is 1, the second is 2, the third is 3… see the examples follows).

This module must be coded in a function which does the followings:

- Accept two arguments by value.
- Display results.

*Example:*

With N = 3, M = 10:

1 2 3

4 5 6

7 8 9

10

With N = 4, M = 10:

1 2 3 4

5 6 7 8

9 10

With N = 4, M = 15:

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15

**Q3. Calculate total of the prime number in the rectangle [3.0]**

When user chooses 3 from main menu, calculate total of all the prime number in the rectangle and return the result to the main function.

This module must be coded in a function which does the followings:

- Accept two arguments by value.
- Return the result to the main function.

Notes: To easier, write a separate function to test a number which is prime number.

*Example:*

With N = 3, M = 10:

The result is:18

With N = 4, M = 10:

The result is:18

With N = 4, M = 15:

The result is:42

**Q4. Count numbers in the last column [3.0]**

When user chooses 4 from main menu, the program count numbers in the last column and return the result to the main function.

This module must be coded in a function which does the followings:

- Accept two arguments by value.
- Return the result to the main function.

*Example:*

With N = 3, M = 10:

The result is:18

With N = 4, M = 10:

The result is:12

With N = 4, M = 15:

The result is:24

**Q5. Exit [0.5]**

When user chooses 5 from main menu, the program will exits.

**Question 2: [10]**

Write a program to accept N strings, store them in separate elements of an array, and then display 3 parts which the first part contains all strings, the second row contains number of even string(string that have even length, example:s is even string if strlen(s)%2==0) and the third contains all even strings.

The program must be divided into modules which do the followings:

- Accept N and all elements of the array from user’s input.
- Display results in three parts.

Note: N < 100

*Example:*

N = 7

a[0] = Hello

a[1] = How

a[2] = are

a[3] = you

a[4] = I

a[5] = am

a[6] = fine

All Stríng:

Hello

How

are

you

I

am

fine

Number of even string: 2

Even string list:

am

fine

**Example Source:**

**epc_a**

co de thi thi nen dua ca loi giai de cac ban nao quen thi co the xem chu nhi???