cpsc quiz 3

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/62

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

63 Terms

1
New cards

iostream

input or output stream

2
New cards

fstream

input and output file stream

3
New cards

ifstream

input file stream

4
New cards

ofstream

output file stream

5
New cards

eof

test for end of input file

6
New cards

cout

standard output

7
New cards

cin

standard input

8
New cards

creating a new file syntax

fstream newfile:

9
New cards

opening a file syntax

newfile.open(“info.txt”, ios::out);

10
New cards

out mode

allows data to be written to a file, ios::out

11
New cards

in mode

allows data to be read from a file, ios::in

12
New cards

close an opened file

newfile.close();

13
New cards

ios::binary

binary mode, data is written to or read from it in pure binary format

14
New cards

read from a file

use either ifstream or fstream class and specify the name of the file

15
New cards

create a file

use either ofstream or fstream and specify name of file

16
New cards

create and open a text file

ofstream Myfile (“filename.txt”)

17
New cards

writing in a file

Myfile « “Writing words”;

18
New cards

iomanip

library used to manipulate output of program, uses showprecision(x), setw(x), showpoiint

19
New cards

showprecision(x)

format to x decimal places

20
New cards

setw(x)

set field/width to x spaces

21
New cards

showpoint

set the format flag for str stream

22
New cards

fail()

true if failbit or hardfail set, false otherwise

23
New cards

bad()

true if badbit set, false otherwise

24
New cards

good()

true if goodbit set, false otherwise

25
New cards

clear()

clear all flags (no arguments), or clear a specific flag

26
New cards

member functions

file stream objects have _________ for special reading and writing, getline, get, put

27
New cards

getline

reads a line of data including whitespace characters, needs name of file stream and name of string

28
New cards

getline syntax

getline(myFile, name);

29
New cards

get

reads a single character from the file

30
New cards

get syntax

gradeFile.get(letterGrade);

31
New cards

put

writes a single character to the file

32
New cards

put syntax

reportFile.put(letterGrade);

33
New cards

outfile.close()

when a program is finished with a file, it must close the file using close like:

34
New cards

binary files

contain data that is not necessarily stored as ASCII text, uses ios::binary flag

35
New cards

abstraction

a recognition of similarities between certain objects, view or representation of an entity that includes only the most significant attributes

36
New cards

order of abstraction languages

machine code, assembler languages, procedural languages, object-oriented programs, modeling languages

37
New cards

procedural abstraction

writing and using subprograms as black boxes, hiding the details of a complex task/process under a method name with parameters

38
New cards

advantages of procedural abstraction

breaking code into pieces, reusing in different situations, easier to test and replace code, hides detail, documentation is easier

39
New cards

data abstraction

collections of data containing data + operations as abstract entities, process of simplifying and representing the whole

40
New cards

advantages of data abstraction

grouping related pieces of information, simplifying the task of reasoning about data, defining and understanding what meaningful operations can be performed on data, easy to modify the code

41
New cards

struct and class

abstraction can be achieved using both ____________ keywords through the concept of abstract classes

42
New cards

struct

user-defined composite data type that groups together variables of different data types under a single name

43
New cards

struct syntax

struct structName {

dataType1 identifier1

dataType2 identifier2

}

44
New cards

member access operator (.)

used to access data into the struct member

45
New cards

member access syntax

structVariableName.memberName

46
New cards

initializing data into a struct member

student newStudent = {“John”, “Brown”, 4.0};

47
New cards

string class

way to represent a sequence of characters as an object of the class, stores the characters a s a sequence of bytes allowing access to a single-byte character

48
New cards

print specific position in string

string_name[position];

49
New cards

print specific string range

string_name.substr(start #, end#);

50
New cards

binary operator +

can be used to perform string concatenation

51
New cards

getline function

to read strings line by line with white space use _______

52
New cards

getline with string syntax

getline(cin, stringName);

53
New cards

relational operators

strings can use ________ to compare

54
New cards

two dimensional array

array (row #, column #)

55
New cards

c-string

specific type of char array that adheres to a convention, fundamentally define by the presence of a null-termination character

56
New cards

c-string header file

#include <cstring>

57
New cards

null characters

if you store a string whose length is less than the array size, the last components are unused and filled with ________

58
New cards

strcpy(s1, s2);

copies string s2 into string s1

59
New cards

strcat(s1, s2);

concatenates string s2 onto the end of string s1

60
New cards

strlen(s1)

returns the length of string s1

61
New cards

strcmp

compares strings character by character

strcmp(s1, s2);

  • returns 0 is they are the same

  • returns negative if s1<s2

  • returns positive if s1>s2

62
New cards

get function

to read a string with blanks, use the _____

63
New cards

get syntax with a string

cin.get(name, 10) → reads 10 characters into name