You are on page 1of 5

Class 20CLC6 – Term I/2020-2021

Course: CSC10001 – Introduction to Programming

Basic Programming Concepts

Prepare your submission


• For multiple-choice and essay questions: Present your work to the PDF file whose name is
<StudentID>.pdf, where StudentID is your student number.
The following guide you how to treat with different types of questions
o Single-choice questions: Each choice is indicated by the circle  Pick the most correct
choice and explain for every other choice (i.e., why you did not choose it)
o Multiple-choice questions: Each choice is indicated by the square  Pick one or many
correct choices and explain for every other choice
o Essay questions: Give a comprehensive answer that covers all aspects of the problem
• For C/C++ programming questions: Present your source codes in C/C++. Do not use any
additional libraries/open sources without permission
o Prepare a separate folder for each question. Name the folder as <StudentID>_<i>,
where StudentID is your student number and i is the question index. For example,
20120001_1, 20120001_2, etc.
o Put all corresponding files (i.e., files of extensions *.cpp, *.h, and data files, etc.) to each
folder. Do not include the intermediate files generated by the Visual Studio compiler.
Do not include the execution files since they are easily affected by viruses.
o Programming questions sometimes require brief explanation. In those cases, present
your arguments to the report file described above.
• Solutions for multiple-choice and essay questions will be provided after the submission
deadlines, while for programming questions, solutions can be alternatively algorithms or
C/C++ source codes.
• Students contact TA through Moodle forum or email (Ms. Nguyễn Ngọc Thảo: nnthao@fit...).

1
A. Multiple-choice questions and essay questions (10pts)

A.1. Consider the following definition of P and identify what P is.


“P is a computer program that translates computer code written in one (high-
level) programming language (the source language) into another (lower level)
language (the target language) to create an executable program. “
 Assembler  Linker  Compiler  Interpreter

A.2. Which of the following is NOT the name of a programming language?


 Anaconda  C#  Eclipse  Go
 Lua  Perl  Ruby  Sublime

A.3. Name at least two IDEs that support C/C++ programming (not to mention Visual Studio). Are
they open-source tools?

A.4. Which of the following figures represents a step, which may be some basic task or action, in
the process?

   

A.5. Assume that the currency rate from USD to VND is 1 USD = 23,181 VND. The following
program converts a given amount of US dollars to Vietnam Dong. Which type of errors that
the program commits?

float fromUSDtoVND(float dollars){


return 23.181 * dollars;
}

 Syntax error  Logic error  Syntax error  None of these.

A.6. Define the following terms: computer program, programming, and algorithm.

A.7. Name all approaches to represent an algorithm. Which one do you prefer? Explain why.

A.8. Design an algorithm by using flowchart to solve the following problem.


“Given a year (which is a positive integer). Check whether the given year is a leap
year , and then output the corresponding number of days in that year.”

A.9. Design an algorithm by using pseudo-code to solve the following problem.


“Given 8 coins that look identical to each other, yet one coin is heavier than the
others. Also given a pan balance. Find the heavy coin in the minimum number of
measurements.“
2
A.10. Consider a program that prompts the user to iteratively input five numbers and then
prints out the sum of given numbers. Identify the errors in the following flowchart and then
correct them if there is any.

3
B. Programming questions (10pts)

You can answer these questions by any possible mean while not worrying about loops or conditions
(which will be available in the following weeks).

B.1. Write a program that prints your name, date of birth and mobile number.
Expected output:
Name : Alexandra Abramov
DOB : July 14, 1975
Mobile : 99-9999999999
B.2. Write a program to compute the perimeter and area of a rectangle with a height of 7 inches
and width of 5 inches.
Expected Output:
Perimeter of the rectangle = 24 inches
Area of the rectangle = 35 square inches
B.3. Write a program to compute the perimeter and area of a circle with a radius of 6 inches.
Expected Output:
Perimeter of the Circle = 37.68 inches
Area of the Circle = 113.04 square inches
B.4. Write a program that accepts two integers from the user and calculates the sum of these
integers.
Test Data :
Input the first integer: 25
Input the second integer: 38
Expected Output:
Sum of the above two integers = 63
B.5. Write a program that accepts the information of two products from the user, for each of
which that includes the unit price (a floating point number) and the number of purchases
(an integer number), and calculates the average value for each product item.
Test Data :
Unit price – Product 1: 15
No. of item – Product 1: 5
Unit price – Product 2: 25
No. of item2 – Product 2: 4
Expected Output:
Average Value = 19.444444

4
B.6. Write a program that uses the asterisk character, ‘*’, to print a full rectangle whose size
(length  height) is 7  4.
Expected output:
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
B.7. Write a program that uses the asterisk character, ‘*’, to print a empty rectangle whose size
(length  height) is 7  4.
Expected output:
* * * * * * *
* *
* *
* * * * * * *
B.8. Write a program that uses the asterisk character, ‘*’, to print a full isosceles triangle whose
height is 4.
Expected output:
*
* * *
* * * * *
* * * * * * *
B.9. Write a program that uses the asterisk character, ‘*’, to print a empty isosceles triangle
whose height is 4.
Expected output:
*
* *
* *
* * * * * * *
B.10. Write a program that uses the hash character, ‘#’, to print the first letter (in uppercase) of
your name.

You might also like