Filters
Question type

Study Flashcards

Write a short C++ code fragment that reads a line of text and echo the line with all uppercase letters replaced by asterisks.

Correct Answer

verifed

verified

#include <iostream>
#include <c...

View Answer

To read a character at a time,or to write a character at a time,declare a character variable ch and write this: cin >> ch;

A) True
B) False

Correct Answer

verifed

verified

To get a complete line of 70 or so character into a C-string is as simple as declaring a long enough C-string and then using the >> operator to extract the line from the input.

A) True
B) False

Correct Answer

verifed

verified

You are writing bulletproof input.Describe a simple situation in this setting where you need to know what character has been entered by the user of your program before you remove it from the input stream.Just describe the setting,do not attempt to write code for this.

Correct Answer

verifed

verified

Your user is entering positive...

View Answer

Write code to define a C-string aString variable,of size 10 but do not initialize it.Use a library C-string library function to copy the C-string literal,"Hello" into aString.

Correct Answer

verifed

verified

#include <cstring...

View Answer

The = sign used to give a variable an initial value in a definition, char ch = 'A'; is different from the = sign in an assignment. ch = 'B';

A) True
B) False

Correct Answer

verifed

verified

A C-string variable with a something in it is always filled with characters.

A) True
B) False

Correct Answer

verifed

verified

The preprocessor symbol NULL and the C-string terminator,the null character share the value 0

A) True
B) False

Correct Answer

verifed

verified

It is legal to assign C-string variables.

A) True
B) False

Correct Answer

verifed

verified

It is illegal to write char message[] ="Go Home!";

A) True
B) False

Correct Answer

verifed

verified

Does this code have a problem? char strVar[] = "Hello"; strcat(strVar," And Good-bye."); cout << strVar << endl;

Correct Answer

verifed

verified

The output is questionable.You might get...

View Answer

On most systems,you don't get a chance to enter the letter when the code given below is run.Write two different code fragments that repair the problem. cout << "Enter a number:\n"; int number; cin >> number; cout << "Enter a letter;\n"; char symbol; cin.get(symbol); cout << number << " " << symbol << endl; Dialog: (Computer output is bolded. ) Enter a number: 21 Now enter a letter: 21 On my system,like many systems,one doesn't get a chance to type the letter.

Correct Answer

verifed

verified

#include <iostream>
using namespac...

View Answer

ANSI/ISO C++ standard includes a string-handling library in the form of the class string.

A) True
B) False

Correct Answer

verifed

verified

Write an if-else statement using a C-string function that reports whether two C-strings variables contain the same C-string.

Correct Answer

verifed

verified

Use strcmp.
if( !strcmp(firstC...

View Answer

Given the following definition and initialization.Write a code fragment including a loop that will overwrite the string greeting,with 'X' in all character position,keeping the length the same.

Correct Answer

verifed

verified

The loop runs from 0 up to the position ...

View Answer

A C-string variable is an array,so it can be indexed to access individual character positions (indexed variables of type character).

A) True
B) False

Correct Answer

verifed

verified

If you want to examine an input value without actually removing it from the input stream,you can apply a member function of cin to the variable ch,which you are to assume is a char type variable.Which of these does this task?


A) cin.get(ch) ;
B) cin.put(ch) ;
C) cin.peek(ch) ;
D) cin.putback(ch) ;

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

Showing 21 - 37 of 37

Related Exams

Show Answer