COMPSCI 1101 SIR JAN ( LAST TERM )

studied byStudied by 68 people
5.0(6)
Get a hint
Hint

A ____ is a named, independent section of C code that performs a specific task and optionally returns a value to the calling statement.

1 / 60

flashcard set

Earn XP

Description and Tags

61 Terms

1

A ____ is a named, independent section of C code that performs a specific task and optionally returns a value to the calling statement.

function

New cards
2

By using that identifier in another part of the program, you can execute the statements contained in the function. This is known as _____.

calling the function

New cards
3

A function is ____. A function can perform its task without interference from or interfering with other parts of the program

independent

New cards
4

A function ______. A task is a discrete job that your program must perform as part of its overall operation, like sending a line of text to a printer.

performs a specific task

New cards
5

A function can _____. When your statement calls a function, the statements a function contains are executed. If you want them to, these statements can pass information back to the calling program.

return a value to the calling statement

New cards
6

There are two types of functions in C Programming

Standard Library functions (built-in) User-defined functions (custom)

New cards
7

The _____ are built-in functions in C programming.

standard library functions

New cards
8

These functions are defined in header files.

standard library functions

New cards
9

The ____ and ____ functions are defined in the stdio.h header file.

printf() scanf()

New cards
10

The ____function is defined in the math.h header file.

sqrt()

New cards
11

LIST THE 5 REASONS WHY FUNCTION USED IN PROGRAMMING

Function code is reusable.

Functions make programs smaller.

Functions make programs easier to write.

Functions lead to improved commenting and readability.

Functions make programs easier to maintain

New cards
12

The first line of a function is called function ____

prototype declaration.

New cards
13

It tells the compiler four things about the function:

( list the four things about the function)

Its data type

Its name

The argument it takes

Who can call it

New cards
14

Like an operand and expression, a _____ also has a data type associated with it.

FUNCTIONS

New cards
15

The data type of a function is the data type of the value it ___.

returns

New cards
16

If the data type is omitted it defaults to_____

int.

New cards
17

Every function must have a_____. Following the rules of identifiers.

name

New cards
18

There can be only one function named ____in a program.

main

New cards
19

The expression following ____is evaluated and its value becomes the return value of the function.

return

New cards
20

The value passed by the function call statement is called an ____

argument.

New cards
21

The arguments passed into a function are known as the function’s _____

parameters.

New cards
22

when passing an argument in function, We passed the _____ not its name.

variable’s value

New cards
23

The C language provides a convenient mechanism whereby the results of a function may be returned to the calling routine.

RETURNING VALUES

New cards
24

The syntax of this (RETURNING VALUES) construct is:

return expression;

New cards
25

This statement indicates that the function is to return the value of the expression back to the calling function

RETURNING VALUES

New cards
26

There are two ways to pass parameters to functions:

They are known generically as “” and “_”.

call by value AND call by reference

New cards
27

In C, all arguments are passed “_______”. This means that each argument passed to a function is evaluated, and its value is passed into the function.

call by value

New cards
28

In a call by_____, instead of passing the value of the argument into the function, a reference to (i.e. the memory address of) the value is passed into the function.

reference

New cards
29

LIST THE DIFFERENT KINDS OF USER DEFINED FUNCTIONS BASED ON OUR NEEDS

  1. Non-returning functions without parameters

  2. Non-returning functions with parameters

  3. Returning functions without parameters

  4. Returning functions with parameters

New cards
30

NON-RETURNING FUNCTIONS WITHOUT PARAMETERS SYNTAX

knowt flashcard image
New cards
31

NON-RETURNING FUNCTIONS WITH PARAMETERS SYNTAX

knowt flashcard image
New cards
32

RETURNING FUNCTIONS WITHOUT PARAMETERS

knowt flashcard image
New cards
33

RETURNING FUNCTIONS WITH PARAMETERS

knowt flashcard image
New cards
34

An outer block variable name is valid in an inner block unless the block redefines

FUNCTION VARIABLES

New cards
35

If an existing variable name is redefined in an inner block, or a new variable name is defined in an inner block, the variable is valid only within that block and is “___” from an outer block.

hidden

New cards
36

the scope of a local variable is the function in which it is ___

defined.

New cards
37

variables that are declared within the bounds of a function or block are referred to as_____

local variables or internal variables..

New cards
38

Variables may also be declared outside of any function block, in the same source file. They are referred to as___

global variables or external variables.

New cards
39

By using recursion in returning functions, it is necessary to use ____ for different outcomes.

multiple return statements

New cards
40

An_____ is a group of memory locations related by the fact that they have the same identifier and data type.

array

New cards
41

____ provides the capability for the programmer to define a set of ordered data items. An array is just the same to a list.

C language

New cards
42

Array must be____ before they are used.

declared

New cards
43

▪ Giving a name to an array takes also the rules _____ in identifiers.

of naming convention

New cards
44

Declaration of an array involves ___the data type of values that will be stored (int, char, float, double) and ___ also the maximum number of elements (dimension) that will be stored.

declaringindicating

New cards
45
<p>syntax of array</p>

syntax of array

New cards
46

Each element of the array can be referenced by means of a number called the_____.

index or subscript

New cards
47

The index must be an____ or an ____

integer integer expression.

New cards
48

In C, the first element is indexed with____

0 (zero).

New cards
49
<p>To access or reference a single element of an array, we state the array name followed by a number in ______.</p>

To access or reference a single element of an array, we state the array name followed by a number in ______.

square brackets

New cards
50

If an array uses an expression as a____, the value of the expression is evaluated first to determine the subscript.

subscript

New cards
51

An____ array element can be used just like variable.

individual

New cards
52

Array _____can also be used in calculations. They are also operands.

elements

New cards
53

Like variables, arrays can also be _____

initialized

New cards
54

This is done by listing the initial _____ of the array.

values (initializers)

New cards
55

The values in the list are separated by , and the entire list is enclosed by_.

commas parentheses

New cards
56

If there is not enough values, elements are set to___

0

New cards
57

C allows to define an array without ____the number of elements (no dimension).

specifying

New cards
58

When this is done the size of the array is determined____, based on the number of ____.

automatically initialized elements

New cards
59

C has no___to prevent the computer from referring to an element that does not exist.

array bounds checking

New cards
60

Storing individual values in each array element requires accessing ____array elements

individual

New cards
61

Size of array is usually passed to a____

function

New cards

Explore top notes

note Note
studied byStudied by 55 people
... ago
5.0(1)
note Note
studied byStudied by 15 people
... ago
5.0(1)
note Note
studied byStudied by 46 people
... ago
4.0(1)
note Note
studied byStudied by 202 people
... ago
4.7(3)
note Note
studied byStudied by 82 people
... ago
5.0(2)
note Note
studied byStudied by 5 people
... ago
5.0(1)
note Note
studied byStudied by 15 people
... ago
5.0(1)
note Note
studied byStudied by 30 people
... ago
5.0(1)

Explore top flashcards

flashcards Flashcard (72)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (45)
studied byStudied by 11 people
... ago
5.0(1)
flashcards Flashcard (54)
studied byStudied by 13 people
... ago
5.0(1)
flashcards Flashcard (67)
studied byStudied by 15 people
... ago
5.0(1)
flashcards Flashcard (131)
studied byStudied by 27 people
... ago
5.0(1)
flashcards Flashcard (20)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (57)
studied byStudied by 162 people
... ago
5.0(1)
flashcards Flashcard (49)
studied byStudied by 38 people
... ago
5.0(1)
robot