0% found this document useful (0 votes)
66 views12 pages

Universiti Tenaga Nasional: College of Information Technology

The document provides information about a final examination for a Bachelor of Information Technology (Hons.) program. It consists of three sections - multiple choice questions, short answer questions, and analytic questions - testing knowledge of structured programming using C. The instructions state there are 100 total marks and students must answer all questions in the provided answer booklet within the allotted 3 hours and 10 minutes.

Uploaded by

nidamajdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views12 pages

Universiti Tenaga Nasional: College of Information Technology

The document provides information about a final examination for a Bachelor of Information Technology (Hons.) program. It consists of three sections - multiple choice questions, short answer questions, and analytic questions - testing knowledge of structured programming using C. The instructions state there are 100 total marks and students must answer all questions in the provided answer booklet within the allotted 3 hours and 10 minutes.

Uploaded by

nidamajdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

UNIVERSITI TENAGA NASIONAL

College of Information Technology





BACHELOR OF INFORMATION TECHNOLOGY (HONS.)


FINAL EXAMINATION
SEMESTER I 2013/2014

STRUCTURED PROGRAMMING USING C
(CISB134)


September 2013

Time allowed: 3 hours + 10 minutes for reading


INSTRUCTIONS TO CANDIDATES

1. The total marks for this exam is 100 marks.
2. There are THREE (3) SECTIONS to this paper: Section A, Section B and Section C.
3. Answer ALL questions in the answer booklet provided.





DO NOT OPEN THIS QUESTION PAPER UNTIL YOU ARE INSTRUCTED TO DO SO
THIS QUESTION PAPER CONSISTS OF 12 PRINTED PAGES INCLUDING THIS PAGE


Page 1 of 12
Page 2 of 12
Semester I 2013/2014 Structured Programming With C
SECTION A: MULTIPLE CHOICE (20 QUESTIONS, 20 MARKS)
Instruction: Answer ALL questions. Please select the BEST answer from the
given choices.

1. Designing algorithm involves developing a list of steps which are arranged in
a specific logical order that produces a solution to a problem when executed.
Below are TRUE about algorithms EXCEPT:
(a) It can be represented by pseudo codes
(b) It can be represented by flow chart
(c) It is an executable code
(d) It must have input and output

2. Select the task represented by the following flow chart symbol in Figure 1:



Figure 1
(a) Terminal
(b) Process
(c) Input/Output
(d) Printer output symbol

3. Which of the followings are the output operations in C?
(i) printf()
(ii) scanf()
(iii) putchar()
(iv) getchar()

(a) (i) and (ii)
(b) (i) and (iii)
(c) (ii) and (iv)
(d) (ii) and (iii)



Page 3 of 12
Semester I 2013/2014 Structured Programming With C
4. A function which calls itself is called
(a) Pre-defined function
(b) User-defined function
(c) Main function
(d) Recursive function

5. The following program describes the use of sentinel-controlled loop. Based on
the program, what is the sentinel value?










(a) N
(b) 5
(c) 0
(d) sum

6. Select the BEST function prototype for a function which receives an integer as
its formal parameters and returns a float value:
(a) int returnMyValue(int);
(b) void returnSum(float);
(c) float returnResult(int);
(d) float convertToFloat(float);





#include <stdio.h>
int main(void)
{
int N;
int sum;
sum = 0;
do{
printf("Enter a number [5 to quit]: ");
scanf("%d",&N);
sum = sum + N;
} while (N != 5);

printf("\nSum = %d\n", sum);
return(0);
}
Page 4 of 12
Semester I 2013/2014 Structured Programming With C
7. How many number of * (asterisk) will be printed by the following program?








(a) 0
(b) 5
(c) Infinite
(d) None of the above

8. Refer to the following program.









What is the global variable defined in the program?
(a) col2
(b) col1
(c) col1 and col2
(d) None of the above





#include <stdio.h>
int col1;
int main(void)
{
int col2;
col1=1;
printf("Enter a number: ");
scanf("%d", &col3);
printf("The value of col1 and col2");
printf(" respectively are\n");
printf("%d %d\n", col1, col2);
return(0);
}
#include <stdio.h>
int main(void)
{
int x = 1;
int count = 1;
while(x <=5)
{
printf("*\n");
count++;
}
return(0);
}
Page 5 of 12
Semester I 2013/2014 Structured Programming With C
9. What is the expected output of the following program?






(a) 89
(b) 0
(c) 69
(d) 56

10. Based on the following program, what is the display output for word1?








(a) hard final exam
(b) This, very hard
(c) final exam hard
(d) This final exam









#include <stdio.h>

int main(void)
{
int result[5] = {56, 69, 89};
printf("%d", result[4]);
return(0);
}
#include <stdio.h>
#include <string.h>

int main(void)
{
char word1[30] = "This final exam";
char word2[30] = "hard, very hard";
strncpy(word1, word2, 4);
printf("word1: %s\n", word1);
return(0);
}
Page 6 of 12
Semester I 2013/2014 Structured Programming With C
SECTION B: SHORT ANSWERS (3 Questions, 30 Marks)
Instruction: Answer ALL questions.

Question 1
Consider a program which calculates the amount (in RM) a customer has to pay when
the following information is entered:
(i) The length and the width of the carpet in feet
(ii) The carpet price per square foot
(iii) The percent of discount
The program should display the final amount after discounted price has been applied.

(a) Draw the flow chart for the program
[4 marks]

(b) What type of control structure that BEST describes the program flow?
[1 mark]

(c) Write a complete C program to solve the problem
[5 marks]

Question 2
Given a = b, b = 5, c = 9, d = 0, e = 0, write the expected output in
each of the followings. Assume the values are reset to original values in each
question:-

(a) printf("%d", a++ - --b * c/b);
[2 marks]

(b) printf("%d", c%b + d++ + ++a * --b);
[2 marks]

(c) e = c%b + d++ + ++a * --b;
printf("%d", e);
[2 marks]
Page 7 of 12
Semester I 2013/2014 Structured Programming With C
(d) e = ++b * --c + d++;
printf("%d", d);
[2 marks]

(e) e = ++d - --e * a;
printf("%d", e);
[2 marks]


Question 3
Given the following programs, write the expected output:
(a)
#include <stdio.h>
void askQ();
int ans(int, int);

void main()
{
askQ();
}

void askQ()
{
int a, b;
printf("Enter 2 integers: ");
scanf("%d%d", &a, &b);
printf("Result is %d\n", ans(a,b));
}

int ans(int num1, int num2)
{
return num1 + num2;
}
[4 marks]








Page 8 of 12
Semester I 2013/2014 Structured Programming With C
(b)
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
char word1[100] = "BOOBOO LOVES TYPING";
char word2[100] = "booboo loves typing";
char word3[100] = " using keyboard";
int total, compare, alpha, space;
alpha = 0, space = 0;

total = strlen(word1);
printf("Total length: %d\n", total);

for(int i=1; i<=total; i++)
{
if (isalpha(word2[i]))
alpha++;
if (isspace(word2[i]))
space++;
}

printf("There are %d alphabets and %d white space in the
sentence\"%s\"\n", alpha, space, word2);

compare = strcmp(word1, word2);

if(compare == 0)
printf("%s is similar to %s\n", word1, word2);
else
printf("%s is not similar to %s\n", word1, word2);

printf(strcat(word1, word3));

return(0);
}
[6 marks]









Page 9 of 12
Semester I 2013/2014 Structured Programming With C
SECTION C: ANALYTIC QUESTIONS (2 QUESTIONS, 50 MARKS)
Attempt ALL questions in this section.

Question 1
As a programmer, we solve problems using Software Development Method (SDM),
which is as follow:
1. Specify the problem requirements.
2. Analyze the problem.
3. Design the algorithm to solve the problem.
4. Implement the algorithm.
5. Test and verify the completed program.
6. Documentation

Suppose a program is to be written to perform a calculation based on the equation
below.
=
+
2
4
2


i) During Analyze the problem step, determine the desired input(s) and output(s)
required by the program.
[4 marks]

ii) During the testing and verification step, how do you know that the result given
by your program is correct?
[2 marks]

iii) What will happen if the user accidentally enter 0 as the value for a?
[4 marks]

iv) Name the error happened in part iii) above?
[2 marks]

v) How can the situation in part iii) be ratified?
[3 marks]
Page 10 of 12
Semester I 2013/2014 Structured Programming With C
vi) Draw a flowchart that describes the design of this program. (Please include the
solution you provide in part v).
[10 marks]


Question 2
i) Given the program in Figure 2 below, identify and rewrite the correct
program statement.
[10 marks]
#include <studio.h>

void main()
{
int sum_even = 0, number = 0; \\initialization

do
{
printf (Enter a number : );
scanf (%d, number);

if (number%2 = 0 && number != 0);
{
sum_even++;
}
}WHILE (number!=0);
printf (Total of even numbers is %c/n, &sum_even);
return (0);
}
Figure 2











Page 11 of 12
Semester I 2013/2014 Structured Programming With C
ii) Given the function in Figure 3 below, rewrite the function using the switch
case command.
[6 marks]
void main()
{
char option;

printf ("Enter your choice : ");
scanf ("%c", &option);

if (option == 'a' || option == 'A')
printf ("A for Apple");
eles
if (option == 'b' || option == 'B')
printf ("B for Ball");
else
if (option == 'c' || option == 'C')
printf ("C for Cat");
else
printf ("D for Dog");

}
Figure 3

iii) Given the program statements in Figure 4,
#include <stdio.h>
void display_data();

int num1 = 5, num2 = 10;

int main()
{
printf ("Number 1 is %d\n", num1);
printf ("Number 2 is %d\n", num2);
display_data();
return(0);
}

void display_data()
{
int num1=100;

printf ("First number is %d\n", num1);
printf ("Second number is %d\n", num2);
}
Figure 4

a) What is the name of the Label (I) statement?
[1 mark]
Label (I)
Label (II)
Label (III)
Page 12 of 12
Semester I 2013/2014 Structured Programming With C
b) What is the type of variable at the Label (II) statement?
(Note: It is not related to the variables data type)
[1 mark]

c) What is the type of variable at the Label (III) statement?
(Note: It is not related to the variables data type)
[1 mark]

d) Briefly describe these TWO (2) types of variables at Label (II) and
Label (III).
[2 marks]

e) Trace the program in Figure 4, what are the outputs of this program?
[4 marks]

















~~ End of Questions ~~

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy