Final Exam

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is a string?

-#string, strings, or cstrings -string name = "c" is invalid needs to be more than on char

What are Arithmetic Operations on Pointers in Pointers and Dereferencing?

->operator -Syntax: classPtr -> classVar(same as (*classPtr).classVar) -classPtr -> classFunc(params)(same as (*classPtr).classFunc(params)) -used with this pointer in member functions -EX: the -> memberVariable = memberVariable;

What is a condition expression?

-A conditional expression has the form: condition ? exprWhenTrue : exprWhenFalse -All 3 operands are expressions -If the condition evaluates to true, then exprWhenTrue is evaluated -If the condition evaluates to false, then exprWhenFalse is evaluated -The condition expression to whichever of those 2 expressions was evaluated -For example, if x is 52, then the conditional expression: y = (x > 50) ? 100 : 3*x evaluates to 100 EX: if(x > 50) { y = 100; } else{ y = 3 * x; } //OR y = (x > 50) ? 100 : 3 * x;

What is a for loop?

-A loop commonly must iterate a specific number of times, such as 10 times -Achievable with a while loop, but this situation is so common that s special kind of loop exists -Loop specified with 3 parts at the top: a loop variable initialization, a loop expression, and a loop variable update EX: for(initialExpression; conditionalExpression; updateExpression){ //loop body }//end of for //statement after the loop

What is the Sentinel Value

-A sentinel value is a special value indicating the end of a list, such as a list of positive integers anding with 0, as in 10, 1, 6, 3, 0 -Loops are commonly used to process an input list of values

What is Destructor in Memory Management in C++?

-A special class member function that triggered when an object is destroyed -Syntax: MyClass::~MyClass(){...} -using ~ (tilde) character before the class name -No paremeters and no return value -Triggered when the object goes out of scope or the delete operator is applies on the pointer pointing to the object -The place to deallocate memory blocks allowed by the constructor using delete operator

What is code in Memory Management in C++?

-Code is stored in a specified section.

What is the use of Delete?

-Does the opposite of the new operator -Deallocates the memory block pointed by the pointer variable delete obj1ptr;

What is a linear search?

-In computer science, a linear search or sequential search is a method for finding an element within a list. It sequentially checks each element of the list until a match is found or the whole list has been searched.

What is swap action (insertion sort)?

-Insertion Sort in C & C++ - Program & Algorithm. ... The insertion sort inserts each element in proper place. The strategy behind the insertion sort is similar to the process of sorting a pack of cards. You can take a card, move it to its location in sequence and move the remaining cards left or right as needed. EX: public void insertionSort() { int in, out; for(out=1; out<nElems; out++) // out is dividing line { long temp = a[out]; // remove marked item in = out; // start shifts at out while(in>0 && a[in-1] >= temp) // until one is smaller, { a[in] = a[in-1]; // shift item to right --in; // go left one position } a[in] = temp; // insert marked item } // end for } // end insertionSort()

What is Sequence in respect to Algorithms?

-Instructions given to the computer are executed in the order in which they were written. In programming terms, the code will run from the top to the bottom

What is Stack in Memory Management in C++?

-LIFO -aka automatic memory -where local variable and formal parameters are stored -a function call adds local variables to the stack and a return removes them -add and remove happen at the top of the stack

What are Pass By Reference in Pointers and Dereferencing?

-Pass by reference (C++ only) Pass-by-reference means to pass the reference of an argument in the calling function to the corresponding formal parameter of the called function. The called function can modify the value of the argument by using its reference passed in

What are nullptr in Pointers and Dereferencing?

-Pointing to nothing, used to initialize pioneer variables

What is swap action (selection sorting)?

-Selection Sort. The selection sort is a combination of searching and sorting. During each pass, the unsorted element with the smallest (or largest) value is moved to its proper position in the array. The number of times the sort passes through the array is one less than the number of items in the array EX: void selectionSort() { int out, in min; for(out = 0; out < nElems - 1; out++)//outer loop { min = out;//save minimum for(in = out + 1; in < nElems; in++)//inner loop if(a[in] < a[min])//if min greater min = in;//a new min found swap(out, min);// swap them }//end of for(outer) }

What is Selection in respect to Algorithms?

-Sometimes we only want an instruction or sequence of instructions to execute when a condition is or is not met. How can we accomplish this in programs? If..else

What is a break?

-The break statement has the following two usages in C++ − When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop. It can be used to terminate a case in the switch statement EX: for(count1 = 1; count1 <= 10; count1++) { if(count1 ==7) break; cout << count1 << endl; } cout << "Broke out of the loop at count = " << count1 << "." << count1 << " and rest skipped." << endl;

What is a continue?

-The continue statement works somewhat like the break statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between. EX: int count, count1; for(count = 1; count <= 10; count++) { if(count == 5) continue; cout << count << endl; cout << "See what we skipped printing above." << endl; cout << endl;

What is the output? double currValue, valuesSum = 0, numValues = 0; currValue = 5; while(currValue > 0) { valuesSum = valuesSum + currValue; numValues = numValues + 1; } //end of while cout << "Average: " << (valuesSum / numValues) << endl; }//end of main()

-The example shown computes the average of an input list of positive integers, end with 0. The 0 is not included in the average -Outputs average of list of positive integers -List end with 0 (sentinel) -Ex: 10 1 6 3 0 yields (10 + 1 + 6 + 3) / 4, or 5

What is Iteration in respect to Algorithms?

-We may want to execute an instruction or a sequence of instructions to execute more than once. How can we accomplish this in programs? Loops!

What is Static Memory Area in Memory Management in C++?

-Where global variables and static variables are stored

What is Heap in Memory Management in C++?

-aka free memory -where the new operator allocates memory and deletes deallocate memory

What are arrays?

-int ages[4] = {35, 26, 18, 27};//declares an array of integers with 4 numbers -float data[20] = {1, 5f, 3.3f, 6.8f, 9.3f, -1.3f}; -float temps[31] = {[1] = -3.0f, [3] = -2.5, [6] = 1.7}};

How do you make comments in C++?

1. // 2. \* *\

Find the error in this code: int *zPtr; //zPtr will reference array int *aPtr = 0; void *sPtr = 0; int number, number2 = 25; int z[5] = {1,2,3,4,5}; ++zPtr; //use pointer to get first value of array number = zPtr; //assign array element 2 (the value 3) to number number = *zPtr[2]; //print entire array z for(int I = 0; i <= 5; i++) cout << zPtr[i] << endl; //assign the value pointed to by sPtr to number number = *sPtr if(number 2 == 1) cout << "Woman" << endl; else; cout << "Man" << endl; while(number2 >= 0) sum += number2; cout << number2 << " " << sum << endl;

1. int *zPtr and int *aPtr: the star goes on the int 2. void *sPtr = 0: cannot be a void 3. if(number 2 == 1) cout << "Woman" << endl; else; cout << "Man" << endl: will never run because its 25 4. while(number2 >= 0) sum += number2; cout << number2 << " " << sum << endl: sum isn't declared

The is the output? int i = -10 int *p = &++I cout << *p << endl; return 0;

11

#include <iostream> using namespace std; int main(){ cout<< "2-D Array of strings" << endl; cout<< endl; //might get warnings related to ISO C++char *cities[ ] = { "Atlanta", "Miami", "Dallas", "Chicago", "Boston", "Seattle"}; for(int i= 0; i< 6; ++i){ cout<< cities[ i] << "\t\t" << &cities[ i] << endl; } cout<< endl; cout<< "The array starts at: " << cities; return 0; }

2-D Array of strings Miami 0x7ffee7713b40 Miami 0x7ffee7713b48 Miami 0x7ffee7713b50 Miami 0x7ffee7713b58 Miami 0x7ffee7713b60 Miami 0x7ffee7713b68

What does this code output: #include <iostream> using namespace std; int main(){ cout<< "3-D Array" << endl; cout<< endl; int a[3][4][2] = { { {2, 6}, {0, 6}, {4, 7}, {1, 5} }, { {3, 2}, {6, 8}, {5, 6}, {4, 5} }, { {7, 5}, {1, 8}, {2, 8}, {6, 4} } };

3-D Array 2 0x7ffeecf4bb20 6 0x7ffeecf4bb24 0 0x7ffeecf4bb28 6 0x7ffeecf4bb2c 4 0x7ffeecf4bb30 7 0x7ffeecf4bb34 1 0x7ffeecf4bb38 5 0x7ffeecf4bb3c 3 0x7ffeecf4bb40 2 0x7ffeecf4bb44 6 0x7ffeecf4bb48 8 0x7ffeecf4bb4c 5 0x7ffeecf4bb50 6 0x7ffeecf4bb54 4 0x7ffeecf4bb58 5 0x7ffeecf4bb5c 7 0x7ffeecf4bb60 5 0x7ffeecf4bb64 1 0x7ffeecf4bb68 8 0x7ffeecf4bb6c 2 0x7ffeecf4bb70 8 0x7ffeecf4bb74 6 0x7ffeecf4bb78 4 0x7ffeecf4bb7c The array starts at: 0x7ffeecf4bb20

What does this output: //The declaration could also be written as follows char color[ ] = "blue"; #include <iostream> #include <cstring> using namespace std; int main() {char color[ ] = { 'b', 'l', 'u', 'e', '\0' }; cout<< strlen(color) ; //4 and NOT 5 return 0; }

4

What is identifiers?

A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).

What is a common error with while loops?

A common error is to use the assignment operator = rather than the equality operator == in a loop expression, resulting in a compilation error

What is a deconstrutor?

A destructor is called for a class object when that object passes out of scope or is explicitly deleted. A destructor is a member function with the same name as its class prefixed by a ~ (tilde). For example: ... A destructor can be declared virtual or pure virtual .

What does this bitwise operation do: x >> y

All bits in x shifted right y bits 12 = 1100 12 >> 1 = 0110 = 6 12 >> 2 = 0011 = 3 12 >> 3 = 0001 = 1

What is a accessor?

An accessor function in C++ and the mutator function are like the set and get functions in C#. They are used instead of making a class member variable public and changing it directly within an object. To access a private object member, an accessor function must be called.

What is a mutator?

An accessor function in C++ and the mutator function are like the set and get functions in C#. They are used instead of making a class member variable public and changing it directly within an object. To access a private object member, an accessor function must be called.

What will be the result of the following code? int b[10] = {1}; cout << b[1] << endl; A. Error B. 0 C. 1 D. Garage value

B. 0

What is printed by the following program? void func(int* b) { *b = 1; } int main() { int* a; int n; a = &n; *a = 0; func(a); cout << *a << endl; } A. 0 B. 1 C. The address of b D. The address of a E. The address of n

B. 1

_____search can be preformed on an unsorted array. A. Binary B. Linear C. Quanternary D. Binary or Linear

B. Linear

The elements of an array are related by the fact that they have the same ____ and ___. A. type, dimension B. name, type C. variables, values D. subscripts, initialization

B. name, type

Local variables and formal parameters are stored in______area of memory A. code B. stack C. static area D. heap

B. stack

What is mixed type cast operation static cast?

C++ Casting Operators. Advertisements. A cast is a special operator that forces one data type to be converted into another. As an operator, a cast is unary and has the same precedence as any other unary operator. The most general cast supported by most of the C++ compilers is as follows − (type) expression.

What Is class structure?

C++ Classes and Objects. Class: The building block of C++ that leads to Object Oriented programming is a Class. It is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class.

What is a constructor?

C++ Constructors. ... A constructor is a special type of member function that initialises an object automatically when it is created. Compiler identifies a given member function is a constructor by its name and the return type. Constructor has the same name as that of the class and it does not have any return type.

What is the helper function?

C++ Program to Illustrate use of Helper Functions. ... A helper function is not meant to be instantiated by end-users but it provides an useful functionality internally used within another class, hence the function is not one of the members of a class rather outside it.

What will be the output? int* thePtr = NULL; cout << thePtr; A. Error B. NULL C. 0 D. "thePtr"

C. 0

What is the output? int count, count1; for(count = 1; count <= 5; count++) { if(count == 3) continue; cout << count << " "; } A. 12345 B. 124 C. 1245 D. 345 E. 123 F. 3

C. 1245

Which of the below is not a basic building block of algorithms? A. Sequence B. Iteration C. Flowchart D. Selection

C. Flowchart

What is the output? #include <iostream> int main() { int n = 0; cout << endl << "The number are: " << endl; do { cout << n << "\t"; n++ } while(n <= 100) { cout << endl; return 0; } A. Print natural number 0 to 99 B. Print natural number 1 to 99 C. Print natural number 0 to 100 D. Print natural number 1 to 99

C. Print natural number 0 to 100

The process of placing the elements of an array in order is called _____ the array. A. Initializing B. Displaying C. Sorting D. Searching

C. Sorting

A pointer is a variable that contains as its value the_______of another variable A. name B. dimension C. address D. declaration

C. address

Which of the below is syntactically correct? A. Boolean myArr[] == {1,0,1} B. boolean myArr[] == {1,0,1} C. bool myArr[] = {1,0,1} D. boolean myArr[] E. None of them

C. bool myArr[] = {1,0,1}

Which of the following statement/s is/are invalid? A. int a[2][3] = {{1,2,3},{4,5,6}}; B. int a[2][3] = {1,2,3,4,5.6}; C. int a[2][] = {1,2,3,4,5,6}; D. int a[][3] = {1,2,3,4,5,6}; E. More than one invalid F. None of them invalid

C. int a[2][] = {1,2,3,4,5,6};

What are constants?

Constants refer to fixed values that the program may not alter and they are called literals. Constants can be of any of the basic data types and can be divided into Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values -Varible type const -const double PI = 3.14 -const int days_in_march = 31;

After the following statement, which option will be true? int* p; int i, k; I = 142; k = I; p = &I; A. k will be 143 B. *k will be 143 C. p will be 143 D. *p will be 142 E. More than one of the above

D. *p will be 142

Which of the following is true? A. An array can store many different types of values. B. An array subscript should normally be of date type float C. If there are fewer initializers list than the number of elements in the array, the remaining elements are initialized to the last value in the initializer list. D. It is an error if an initializer list contains more initializers than there are elements in the array.

D. It is an error if an initializer list contains more initializers than there are elements in the array.

What does append( ) do?

Extends the string by appending additional characters at the end of its current value: str1.append(" Adios!!");

What does strlen( ) do?

Get string length Returns the length of the C string str. The length of a C string is determined by the terminating null-character: A C string is as long as the number of characters between the beginning of the string and the terminating null character (without including the terminating null character itself). This should not be confused with the size of the array that holds the string. For example: char mystr[100]="test string"; defines an array of characters with a size of 100 chars, but the C string with which mystr has been initialized has a length of only 11 characters. Therefore, while sizeof(mystr) evaluates to 100, strlen(mystr) returns 11. In C++, char_traits::length implements the same behavior.

What is This?

In C++ programming, this is a keyword that refers to the current instance of the class. There can be 3 main usage of this keyword in C++. It can be used to pass current object as a parameter to another method. It can be used to refer current class instance variable.

What is the bottom up approach?

It refers to a style of programming where an application is constructed starting with existing primitives of the programming language, and constructing gradually more and more complicated features, until the all of the application has been written.

What is the top-down approach?

It starts out by defining the solution at the highest level of functionality and breaking it down further and further into small routines that can be easily documented and coded

What is a binary search?

List must be in order; looks in middle; goes left if lower and right if greater

What does strchr( ) do?

Locate first occurrence of character in string Returns a pointer to the first occurrence of character in the C string str. The terminating null-character is considered part of the C string. Therefore, it can also be located in order to retrieve a pointer to the end of a string. if (strchr(string1, 'J') != NULL) { // 'J' exists in string1?

What does strrchr( ) do?

Locate last occurrence of character in string Returns a pointer to the last occurrence of character in the C string str. The terminating null-character is considered part of the C string. Therefore, it can also be located to retrieve a pointer to the end of a string. if (strrchr(string1, 'J') != NULL) { // searches for 'J' in string1, in reverse

What is the incline function?

The inline functions are a C++ enhancement feature to increase the execution time of a program. Functions can be instructed to compiler to make them inline so that compiler can replace those function definition wherever those are being called.

What does this bitwise operation do: x ^ y

The last operator is the bitwise XOR (^), also known as exclusive or. When evaluating two operands, XOR evaluates to true (1) if one and only one of its operands is true (1). If neither or both are true, it evaluates to 0. Consider the expression 6 ^ 3:

What does this output: #include <iostream> using namespace std; size_tgetSize( double * ); // prototype //type size_t-an alias for unsigned int int main() {double arr2[ 20 ]; cout<< "The number of bytes in the arr2 is " << sizeof( arr2 ); cout<< "\nThenumber of bytes returned by getSizeis "<< getSize( arr2 ) << endl; return 0; } // return size of ptrsize_tgetSize( double *ptr){ return sizeof( ptr); }

The number of bytes in the arr2 is 160 The number of bytes returned by getSize is 8

What is the output? int sum = 0; int x = -1; while(x <= 10) { sum += x; x++; } cout << "The sum is: << sum << endl;

The sum is = 55

What is a floating point number?

The term floating point refers to the fact that a number's radix point (decimal point, or, more commonly in computers, binary point) can "float"; that is, it can be placed anywhere relative to the significant digits of the number.

What are the boxes in a flow chart?

They represent assignment and other instruction

What are the parallelograms in a flow chart?

They represent input and output

What are the Ovals represent in a flow chart?

They represent start and end of a program

What are the diamonds in a flow chart?

They represent the selection statements (if-statements)

What are signed and unsigned variables?

Unsigned can hold a larger positive value, and no negative value. Unsigned uses the leading bit as a part of the value, while the signed version uses the left-most-bit to identify if the number is positive or negative. signed integers can hold both positive and negative numbers.

What does this output: #include <iostream> using namespace std; int main(){ const int arr3Size = 5; int arr3[arr3Size] = {15, 3, 19, 7, 1}; int *arr3Ptr1 = arr3; int *arr3Ptr2 = &arr3[ 0 ]; cout<< "arr3 pointer1 points to: " << arr3Ptr1 << endl; cout<< "arr3 pointer2 points to: " << arr3Ptr2 << endl; cout<< "arr3 pointer1 has a value: " << *arr3Ptr1 << endl; cout<< "arr3 pointer2 has a value: " << *arr3Ptr2 << endl; cout<< "arr3 pointer1+2 points to: " << arr3Ptr1+2 << endl; cout<< "arr3 pointer2+3 points to: " << arr3Ptr2+3 << endl; cout<< "arr3 pointer1+2 has a value: " << *arr3Ptr1+2 << endl; cout<< "arr3 pointer2+3 has a value: " << *arr3Ptr2+3 << endl; cout<< "(arr3 pointer1+2) has a value: " << *(arr3Ptr1+2) << endl; cout<< "(arr3 pointer2+3) has a value: " << *(arr3Ptr2+3) << endl; cout<< "arr3Ptr1[3] refers to: " << arr3Ptr1[3] << endl; return 0; }

arr3 pointer1 points to: 0x7ffeebcdcb50 arr3 pointer2 pointer to: 0x7ffeebcdcb50 arr3 pointer1 has a value: 15 arr3 pointer2 has a value: 15 arr3 pointer1+2 points to: 0x7ffeebcdcb58 arr3 pointer2+3 points to: 0x7ffeebcdcb5c arr3 pointers1+2 has a value: 17 arr3 pointers2+3 has a value: 18 (arr3 pointers1+2) has a value: 19 (arr3 pointers2+3) has a value: 7 arr3Ptr1[3] refers to: 7

What does this bitwise operation do: x & y

each bit in x AND each bit in y Bitwise AND works similarly. Logical AND evaluates to true if both the left and right operand evaluate to true. Bitwise AND evaluates to true only if both bits in the column are 1. Consider the expression 5 & 6. Lining each of the bits up and applying an AND operation to each column of bits:

What does this bitwise operation do: x | y

each bit in x OR each bit in y and then apply the operation to each column of bits. If you remember, logical OR evaluates to true (1) if either the left or the right or both operands are true (1). Bitwise OR evaluates to 1 if either bit (or both) is 1. Consequently, 5 | 6 evaluates like this:

What is constructor overloading?

int main() { // Constructor Overloading // with two different constructors // of class name construct o; construct o2( 10, 20); o.disp(); o2.disp(); return 1; }

What does strcmp( ) do?

int strcmp ( const char * str1, const char * str2 ); Compare two strings Compares the C string str1 to the C string str2. This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminating null-character is reached. This function performs a binary comparison of the characters. For a function that takes into account locale-specific rules, see strcoll. char* subStr= nullptr; //Or NULL or 0if (strcmp(string1, string2) == 0)if (strcmp(&string1[3], "Allen") == 0) subStr= &string1[6];if (strcmp(subStr, string2) == 0)

What is the use of New?

int* thePtr = nullptr; thePtr = new int; *thePtr = 49; -Allocates memory in the heap for the given type and returns a pointer pointing to the allocated memory CreatNew* obj1ptr = nullptr; obj1ptr = new CreateNew; (*obj1ptr).printDetails();

What is post decrement?

value of i is decremented after assigning it to variable i

What is pre decrement?

value of i is decremented before assigning it to the variable i

What is post increment?

value of i is incremented after assigning it to the variable i

What is pre increment?

value of i is incremented before assigning it to the variable

What are Pointer Operators in Pointers and Dereferencing?

-The address operator(&) is a unary operator that returns the memory address of its operand, for example: assuming the declarations -The statement assigns the address of the variable y to pointer variable yPtr

What are the 3 basic building block of an Algorithm?

1. Sequence 2. Selection 3. Iteration

int row = 3; int column; while(row >= 1) { column = 1; while(column <= 4) { cout << ( row % 2 ? "<:>"); column++; } row--; cout << endl; }

>>>> <<<< >>>>

What is member functions?

A member function of a class is a function that has its definition or its prototype within the class definition like any other variable. It operates on any object of the class of which it is a member, and has access to all the members of a class for that object.

What is an assignment statement?

A statement that sets a variable to a specified value. EX: num1 = 5; num1 = num1 + 7; num1 += 1; num1 = 5 + 9 * 15 - num2;

What does this bitwise operation do: x << y

All bits in x shifted left y bits For example, consider the number 3, which is binary 0011: 3 = 0011 3 << 1 = 0110 = 6 3 << 2 = 1100 = 12 3 << 3 = 1000 = 8

What is char?

Characters -char firstInitial = 'A', midInitial -char var = "d" doesn't work

An array that uses 2 subscripts is referred to as a(n)_______array. A.Subscripted array B. Vector C. Linear array D. 2-D array

D. 2-D array

What is data members?

Data members (C++ only) Data members include members that are declared with any of the fundamental types, as well as other types, including pointer, reference, array types, bit fields, and user-defined types. ... A class can have members that are of a class type or are pointers or references to a class type.

What does erase( ) do?

Erases part of the string, reducing its length: str1.erase(5, 3)//erasing 2 characters starting at position 1

What is function overloading?

Function Overloading in C++ You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.

What does replace( ) do?

Replaces the portion of the string that begins at character pos and spans len characters (or the part of the string in the range between [i1,i2)) by new contents: str7.replace(2, 12, "ese Mangoes are tasty and so are the") //replace 12 chars starting from 2

What does this bitwise operation do: ~x

The bitwise NOT operator (~) is perhaps the easiest to understand of all the bitwise operators. It simply flips each bit from a 0 to a 1, or vice versa. Note that the result of a bitwise NOT is dependent on what size your data type is! Assuming 4 bits: 4 = 0100 ~4 = 1011 = 11 (decimal) Assuming 8 bits: 4 = 0000 0100 ~4 = 1111 1011 = 251 (decimal)

What does strcpy( ) do?

char * strcpy ( char * destination, const char * source ); Copy string Copies the C string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point). To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C string as source (including the terminating null character), and should not overlap in memory with source. strcpy(string3, subStr);

What does this code output: #include <iostream> using namespace std; int main() { char c; short s; int i; long l; float f; double d; long double ld; // variable of type long double int array[ 20 ]; int *ptr= array; // variable of type int * cout<< "sizeofc = " << sizeofc << endl; cout<< "sizeof(char) = " << sizeof( char ) << endl ;cout<< "sizeofs = " << sizeofs << endl; cout<< "sizeof(short) = " << sizeof( short ) << endl; cout<< "sizeofi= " << sizeofi<< endl; cout<< "sizeof(int) = " << sizeof( int ) << endl; cout<< "sizeofl = " << sizeofl << endl; cout<< "sizeof(long) = " << sizeof( long ) << endl; cout<< "sizeoff = " << sizeoff << endl; cout<< "sizeof(float) = " << sizeof( float ) << endl; cout<< "sizeofd = " << sizeofd << endl ;cout<< "sizeof(double) = " << sizeof( double ) << endl; cout<< "sizeofld= " << sizeofld<< endl; cout<< "sizeof(long double) = " << sizeof( long double ) << endl; cout<< "sizeofarray = " << sizeofarray << endl; cout<< "sizeofptr= " << sizeofptr<< endl; int arraySize= sizeof(array)/sizeof(int); return 0; }

sizeof c = 1 sizeof(char) = 1 sizeof s = 2 sizeof(short) = 2 sizeof i = 4 sizeof(int) = 4 sizeof l = 8 sizeof(long) = 8 sizeof d = 8 sizeof(double) = 8 sizeof ld = 16 sizeof(long double) = 16 sizeof array = 80 sizeof ptr = 8

What does at( ) do?

std::string::at can be used to extract characters by characters from a given string. char ch1 = str1.at(0);


Conjuntos de estudio relacionados

Web Apps I (File extension terminology and definitions)

View Set

Mastering Assignment 3 : lipids and membranes

View Set

Evolve: Maternity - Women's Health/Disorders

View Set

Insurance Pre-licensing : Chapter 4 quiz

View Set

Biology Week 1: Tragedy of the Commons

View Set

BA302 Chapter 4 Individual Attitudes and Behaviors

View Set