Introduction to Computer Programming (GSDR2222)
Higher Institute of Transport and Logistics (HITL)
Semester: Second Semester
Level: 200
Year: 2017
School/Faculty: HITL DEPARTMENT: General Studies LECTURER(S): Dr. DADA Jean Pierre
Level: 100 SEMESTER: Second Academic Year: 2016/2017
COURSE CODE: TLGS1222 COURSE TITLE: Into. To Computer Programing
DATE: HALL: TIME: 2hrs
Instructions: Answer all questions.
THE UNIVERSITY OF BAMENDA
P.O BOX 39 Bambili
REPUBLIC OF CAMEROON
Peace-Work-Fatherland
0 .
. 17 0
r.
Exercise 1: (21 marks): The program below calculates the surface of a rectangle. It
has 15 lines
#include <stdio.h>
/* This program calculates the surface of a rectangle */
int main()
{
float length,width,surface;
printf("%f”,&length);
printf("##### Enter the width of your rectangle #####\n");
Scanf("%",&width;
surface=length*width;
printf("The length is:%0.2f\n",length);
printf("The width is:%0.2f\n",width);
printf("His surface is:%0.4f\n",surface);
return 0;
}
1.1 Rewrite and explain all in 15 line codes of this program (15 marks)
1.2 Design the screen with all what will be displayed by using the values length = 10 and
width = 20.55 (6 marks)
Exercise 2 (31 Marks): The print screen below represents a program. The aim of this
diagram is to calculate the power five of a number N, using the formula X =N
5
.
1. What software has been used to type this program? (2 marks)
2. Write the entire program representing the print-screen (15 marks)
3. As the program is typed, how do you compile it? (2 marks)
4. As the program is compiled, how do you run it? (2 marks)
5. If you want to compile and run the program at the same time, what do you do? (2
marks)
6. What happens in the computer as you compile the program? (2 marks)
7. What is the main difference between source file and executable file? (2 marks)
8. As your program is good, you want to give it to someone in the United States, what
file (source file or executable file) are you going to send?
www.schoolfaqs.net
8.1 if you do not want the person to identify the codes typed (2 marks)
8.2 if you want the person to modify your program (2 marks)
Exercise 3 (18 marks):
The tank is used to carry fuel in a truck has the following figure:
If V is the volume of the tank, then the formula is V =
|
−
|
.
1) Write a C program able to calculate the volume of this tank with the conditions
• H, R
1
and R
2
are inserted when the program is running
• The number of decimal is 4 when data and displayed on the screen (10 marks)
2) Simulate the program and design the screen with what will be displayed. You should
use the values H=10, R
1
= 1m, R
2
= 2m and = 3.14 (10 marks)
www.schoolfaqs.net