Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

CP2-Module 3

Character and String Manipulation: <cstring> and <string>

QuestionAnswer
Compares up to num characters of the C string str1 to those of the C string str2 strlen() strcmp() isalpha() strncmp() strncmp()
This header declares a set of functions to classify and transform individual characters. ctype.h math.h cstdlib.h iostream ctype.h
Returns true if character expression is a digit 0 through 9 otherwise false. isdigit() isalpha () isalnum() isspace() isdigit()
What is the output of the given program? #include <iostream> #include <ctype.h> int main () { int i=0; char str[]="first line \n second line \n"; while (!iscntrl(str[i])) { putchar (str[i]); i++; } return 0; } first line
Returns true if character expression is either a letter or a digit otherwise false isdigit() isalnum () isalpha() isspace() isalnum ()
Check if a character is an uppercase letter isxdigit() Isupper() isupper() toupper() isupper()
What is the output of the given program? #include <iostream> #include <ctype.h> int main () { int i=0; char str[]="first line "; return 0; } Group of answer choices Error FIRST LINE blank screen first line blank screen
What is the output of the given program? #include <cctype> #include <iostream> #include <cstring> using namespace std; int main() { char str[] = "THIS IS A TEST"; for (int i=0; i<strlen(str); i++) putchar(tolower(str[i])); return 0; } this is a test
Returns true provided character expression is a lowercase letter otherwise it returns false islower() tolower() toupper() isupper() islower()
Which of the following is NOT a cstring function? strcpy() strncpy() strcat() sqrt() sqrt()
What is the output of the given program? #include <iostream> #include <string> using namespace std; int main () { string str1 = "This is a test"; string str2 = "test"; cout << "Word is found at index " << str1.find(str2,0); return 0; } Word is found at index 10
The sequence of contiguous characters in memory is called _____________. Arrays Character strings Functions Identifiers Character strings
Which method do we use to append more than one character at a time? both append and operator += data operator += append append
What is the output of the following program? #include <iostream> #include <string> using namespace std; int main () { string str1 = "Trust"; int len = str1.size() cout << len << endl; return 0; } error 7 5 4 error, no semi-colon after "int len = str1.size()" :-)
If two strings are identical, then the strcmp() function returns: 1 -1 0 Error 0
Which of the following function converts a numerical value to string? tolower to_string toupper stoi to_string
Strings are accessed by variables of what type? boolean double int char char
What is the output of the following? #include <iostream> #include <string> using namespace std; int main () { string myString = "Lovely"; cout << myString.substr(0,4); return 0; } Group of answer choices ely Lovely Error Love Love
What is the output of the following program? #include <string> #include <iostream> using namespace std; int main() { string str; cin>>str; cout<<str; return 0; } Group of answer choices error str input provided by user 0 input provided by user
Which of the following function is used to concatenate strings? strcpy() strcmp() strcat() stod() strcat()
Converts lowercase letter to uppercase isspace() isprint() toupper() isupper() toupper()
The same as the two-argument strcmp except that at most Limit characters are compared. strncmp() put() strcat() strcmp() strncmp()
What is the output of the program? #include <cstring> #include <iostream> int main () { char str[80]; strcpy (str,"these "); strcat (str,"strings "); strcat (str,"are "); strcat (str,"concatenated."); puts (str); return 0; } these strings are concatenated.
Checks if a character is blank isblank() isgraph() isalpha() isalnum() isblank()
Check if a character is alphanumeric isalnum() isdigit() isprint() isblank() isalnum()
It is a sequence of characters String Character Identifier Data Type String
Which of the following is NOT a cstring function? strncpy() strcpy() strcat() sqrt() sqrt()
Which of the following compares two string values? strcpy() strcmp() strlen() strcat() strcmp()
Which of the following operators is not a comparison operator? <= >= #= == #=
Which of the following function converts a string to double? stod stoll stoi stof stod
Which of the following operator can be used also in strings? - > @ + + (concatenation operator)
A string value should always have a _________ enclosed parenthesis Double quotation mark semicolon ampersand Double quotation mark
Which operator is suitable for the concatenation function of a string class? > operator – operator < operator + operator + operator
What is the output of the following program? #include <iostream> #include <string> #include <cmath> using namespace std; int main () { string s = "54.55"; double php = stod(s); cout << "A dollar is equivalent to " << php return 0; } Error, syntax error at cout statement.
If b = “3.1416” then a is a: float integer double string string, because it is enclosed in double quotation marks.
What is the output of the following program? #include <iostream> #include <string> using namespace std; int main () { string myString = "Hello"; cout << myString[0]; return 0; } H 0 Error Blank output H
What is the output of the following program? #include <string> #include <iostream> using namespace std; int main() { string x = "Bad "; cout << x.append(Romance); return 0; } Error Bad Romance Romance Bad Error
Created by: Easy Kwatro
Popular Computers sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards