Sei sulla pagina 1di 2

TUTORIAL 07

BMIS 31121 - ITP

BMIS 31121 INTRODUCTION TO PROGRAMMING


TUTORIAL 07

ANSWER THE FOLLOWING QUESTIONS.


Answer the following questions:
1
2
3
4

What is function?
What are the purposes of function?
Explain TWO (2) types of function. Give an example.
Explain the following:
i
Function definitions
ii
Function declarations
iii
Function call
With appropriate example.

5
6
7
8
9
10
11

What are the components of function definitions?


What are the components of function declarations?
Define parameter and argument.
Describe TWO (2) scopes of variable.
Write sample codes of declaration of variables in different scopes.
Discuss Two (2) types of function calls.
Write sample codes using function to output the following (you can create your own function)
a

*********
HELLO
*********
HAPPYHAPPYHAPPYHAPPYHAPPYHAPPY

12 Categorize the following function declaration:


a

char arrange (char n1, char n2);

int mean(int x, int y);

int findmax(int n1, int n2)

void exchange(int a, int b);

void init(void)

sub_num();

void printhw();

int add_number (void);

NHMR/FBM FEB 2015

TUTORIAL 07

BMIS 31121 - ITP

13 Write a function for the following:


a

Find the square of a number.

Average of three numbers

Print Hello World

14 Assume that you have functions print_h, print_i, print_m, and print_o, each of which
draws a large block letter (for example, print_o draws a block letter O). What is the effect of
executing the following main function?
int main(void)
{
print_h();
print_i();
printf(\n\n\n);
print_m();
print_o();
print_m();
return (0);
}

15 What does the following function do?

int main(void)
{
nonsense ();
nonsense ();
nonsense ();
return (0);
}

16 What does the following main function do? (see Question 15)

void nonsense(void)
{
printf(* * * * *\n);
printf(*
*\n);
printf(* * * * *\n);
}

NHMR/FBM FEB 2015