Can any one correct these true and false answer for me? I did not but I
don't know if they are all corrected. THanks
True. In C++, resersed words the same as predefined identifiers.
False. An indentifier can be any sequence of digits, leters, and the
underscore.
True. When trying to store a double value in an int variable, the double
value is rounded to the nearest interger.
False. An if statement cannot be nested in a switch statement, but a switch
statement can be nested in an if statement.
True. The execution of a break statement in a while loop terminates the
loop.
True. A function definition consists of the function heading and the body of
the function.
True. Parameters allow the programmer to use different values each time the
functions is called.
False. The execution of the return statement in a user-defined function
terminates the program.
True. It is not necessary to specify the names of formal parameters in a
function prototype.
False. The return statement
Return x +1;
First returns the values of x and then increments the values of
x.
True. The following return statement return the value 10.
Return 10,16;
True. The following statement in a value-returning function is legal.(
assume that all variables are properly declared)
If (x%==0)
Return x;
Else
Return x +1;
True. Given the function prototype
Float test();
The statement
Cout<<test;
Is legal because the function test has no parameters.
True. Given the function prototype
Double testAlpha (int u, char v, double t);
The following statement is legal.
Cout<<testAlpha(5, 'A', 2);
False. If a formal parameters is a value parameter and the corresponding
actual parameters is a variable, the actual parameter can be modified.
False. If an ampersand, & is attached to the data type of a formal
parameter, the corresponding actual parameter must be a variable.
True. A value parameter only changes its own content without changing the
value of the actual parameter.
True. A variable name can be passed to a value parameter.
False. The corresponding actual parameter for a reference parameter can be
any expression
True. Any parameter the receives a value and also sends a value outside the
function must be declared as reference parameter.
True. If a formal parameter is a reference parameter, the corresponding
actual parameter must be a varialble
True. The pass by value mechanism must be used if the calling code is to
receive values back from the function.
True. A variable declared outside of every block is called a global
variable.
True. In a program global constants have no side effects.
False. The scope of a formal parameter and the scope of a local variable
declared in the outer block of a function body is the same
True. In C++, function definitions cannot be nested, that is, the definition
of one function cannot be enclosed in the body of another function.
True. A static variable works the same way as global variable because memory
for the static variables remains allocated during program execution.
True. The following is a legal C++ function definition
Void funcTest(int& u, double& v);
{
Cout<<u<<" "<<v<<endl;
}
False. The output of the C++ code
Int alpha =5;
Int beta=10;
Alpha = alpha +5;
{
Int alpha;
Alpha=20;
beta= beta +5;
}
Cout<<alpha<<" "<<beta<<endl;
Is: 10 15
True. In C++ , when declaring an array as a formal parameter, the size of
the array must be specified within square brackets.
True. The word const is used before the array declaration in a function
heading to prevent the function from modifying the array.
False. A struct can be passed as a parameter to a function by value or by
reference.
True. A function cannot return a value of a type struct
True. The Address operator is a urary operator that returns the address of
its operand.
True. Any number can be directly assigned to a pointer variable. 22 5240
Richard wrote: Can any one correct these true and false answer for me? I did not but I
I don't understand your statement "I did not but I don't know ..."
don't know if they are all corrected. THanks [...]
And, no, we don't do homeworks.
V
"Richard" <no********@yahoo.com> wrote in message
news:ja******************************@comcast.com. .. Can any one correct these true and false answer for me? I did not but I don't know if they are all corrected. THanks
True. In C++, resersed words the same as predefined identifiers. False. An indentifier can be any sequence of digits, leters, and the underscore.
1) How coud we possibly know if the answers are correct, when you haven't
given the questions???
2) If this is some kind of homework, we don't do that here.
3) A lot of what you've written is badly misspelled and/or makes no sense.
This first "answer" is a good example: "resersed words the same as
predefined identifiers". What does that mean?
-Howard
"Howard" <al*****@hotmail.com> wrote in message
news:eT********************@bgtnsc04-news.ops.worldnet.att.net... "Richard" <no********@yahoo.com> wrote in message news:ja******************************@comcast.com. .. Can any one correct these true and false answer for me? I did not but I don't know if they are all corrected. THanks
True. In C++, resersed words the same as predefined identifiers. False. An indentifier can be any sequence of digits, leters, and the underscore.
1) How coud we possibly know if the answers are correct, when you haven't given the questions???
Hmm... I guess those _are_ the questions, and the answers are the true/false
you give before them? Very odd way of listing the questions and answers in
that case...
-Howard
Richard wrote: Can any one correct these true and false answer for me? I did not but I don't know if they are all corrected. THanks
<snip>
C++ is a case-sensitive language, but your post breaks the rules
several times. For example a return statement must use a lower-case
'r'.
Earl Purple wrote: Richard wrote:
Can any one correct these true and false answer for me? I did not but I don't know if they are all corrected. THanks
<snip>
C++ is a case-sensitive language, but your post breaks the rules several times. For example a return statement must use a lower-case 'r'.
Actually it must use *two* lower-case 'r's.
V
On Mon, 12 Dec 2005 12:46:10 -0500, Victor Bazarov
<v.********@comAcast.net> wrote: Earl Purple wrote: Richard wrote:
Can any one correct these true and false answer for me? I did not but I don't know if they are all corrected. THanks
<snip>
C++ is a case-sensitive language, but your post breaks the rules several times. For example a return statement must use a lower-case 'r'.
Actually it must use *two* lower-case 'r's.
V
So THAT'S why my source wouldn't compile:
retuRn someValue;
}
DOH!
"Richard" <no********@yahoo.com> wrote in message
news:ja******************************@comcast.com. .. Can any one correct these true and false answer for me? I did not but I don't know if they are all corrected. THanks
True. In C++, resersed words the same as predefined identifiers.
FALSE
False. An indentifier can be any sequence of digits, leters, and the underscore.
FALSE
True. When trying to store a double value in an int variable, the double value is rounded to the nearest interger.
TRUE
False. An if statement cannot be nested in a switch statement, but a
switch statement can be nested in an if statement.
FALSE
True. The execution of a break statement in a while loop terminates the loop.
TRUE
True. A function definition consists of the function heading and the body
of the function.
TRUE
True. Parameters allow the programmer to use different values each time
the functions is called.
TRUE
False. The execution of the return statement in a user-defined function terminates the program.
FALSE
True. It is not necessary to specify the names of formal parameters in a function prototype.
TRUE
False. The return statement
Return x +1;
First returns the values of x and then increments the values
of x.
FALSE
True. The following return statement return the value 10.
Return 10,16;
FALSE
True. The following statement in a value-returning function is legal.( assume that all variables are properly declared)
If (x%==0)
Return x;
Else
Return x +1;
FALSE True. Given the function prototype Float test();
The statement
Cout<<test;
Is legal because the function test has no parameters.
FALSE
True. Given the function prototype
Double testAlpha (int u, char v, double t);
The following statement is legal.
Cout<<testAlpha(5, 'A', 2);
TRUE
False. If a formal parameters is a value parameter and the corresponding actual parameters is a variable, the actual parameter can be modified.
FALSE
False. If an ampersand, & is attached to the data type of a formal parameter, the corresponding actual parameter must be a variable.
TRUE
True. A value parameter only changes its own content without changing the value of the actual parameter.
TRUE
True. A variable name can be passed to a value parameter.
TRUE
False. The corresponding actual parameter for a reference parameter can be any expression
FALSE
True. Any parameter the receives a value and also sends a value outside
the function must be declared as reference parameter.
FALSE
True. If a formal parameter is a reference parameter, the corresponding actual parameter must be a varialble
TRUE
True. The pass by value mechanism must be used if the calling code is to receive values back from the function.
FALSE
True. A variable declared outside of every block is called a global variable.
TRUE
True. In a program global constants have no side effects.
FALSE
False. The scope of a formal parameter and the scope of a local variable declared in the outer block of a function body is the same
FALSE
True. In C++, function definitions cannot be nested, that is, the
definition of one function cannot be enclosed in the body of another function.
TRUE
True. A static variable works the same way as global variable because
memory for the static variables remains allocated during program execution.
FALSE True. The following is a legal C++ function definition
Void funcTest(int& u, double& v);
{
Cout<<u<<" "<<v<<endl;
}
TRUE False. The output of the C++ code
Int alpha =5;
Int beta=10;
Alpha = alpha +5;
{
Int alpha;
Alpha=20;
beta= beta +5; }
Cout<<alpha<<" "<<beta<<endl; Is: 10 15
FALSE
True. In C++ , when declaring an array as a formal parameter, the size of the array must be specified within square brackets.
TRUE
True. The word const is used before the array declaration in a function heading to prevent the function from modifying the array.
FALSE
False. A struct can be passed as a parameter to a function by value or by reference.
FALSE
True. A function cannot return a value of a type struct
FALSE
True. The Address operator is a urary operator that returns the address of its operand.
TRUE
True. Any number can be directly assigned to a pointer variable.
FALSE
On Mon, 12 Dec 2005 12:52:07 -0500, dave wrote: True. When trying to store a double value in an int variable, the double value is rounded to the nearest interger. TRUE
AFAIK, it rounds towards zero (truncates). So, FALSE.
- Jay
On Mon, 12 Dec 2005 12:52:07 -0500, dave wrote: "Richard" <no********@yahoo.com> wrote in message news:ja******************************@comcast.com. ..
True. The execution of a break statement in a while loop terminates the loop.
TRUE
Usually. But:
while (!done)
{
for (int i = 0; i < 10; ++i)
{
if (i == 3)
break;
}
}
Is the break statement considered "in the while loop"? True. Given the function prototype Float test();
The statement
Cout<<test;
Is legal because the function test has no parameters.
FALSE
Perfectly *legal* (mis-casing of "cout" ignored). It prints out the
address of the function test. It will work even if the function has
parameters. (Of course, it will not actually invoke the function in any
case without parens.)
False. If an ampersand, & is attached to the data type of a formal parameter, the corresponding actual parameter must be a variable.
TRUE
Unless it's const (e.g. "const int &"), in which case it can be bound to a
temporary.
True. If a formal parameter is a reference parameter, the corresponding actual parameter must be a varialble
TRUE
Same as before - unless it's const. True. The following is a legal C++ function definition
Void funcTest(int& u, double& v);
{
Cout<<u<<" "<<v<<endl;
}
TRUE
FALSE. The trailing semi-colon on the "funcTest" line results in a syntax
error.
True. In C++ , when declaring an array as a formal parameter, the size of the array must be specified within square brackets.
TRUE
FALSE.
int main(int argc, char* argv[])
{
}
True. The word const is used before the array declaration in a function heading to prevent the function from modifying the array.
FALSE
TRUE. (What else would the const do?)
False. A struct can be passed as a parameter to a function by value or by reference.
FALSE
TRUE.
struct Point { int x, y; }
void myFunc(Point inp, Point& outp);
- Jay
Jay Nabonne wrote: On Mon, 12 Dec 2005 12:52:07 -0500, dave wrote:
True. When trying to store a double value in an int variable, the double value is rounded to the nearest interger.
TRUE
AFAIK, it rounds towards zero (truncates). So, FALSE.
It depends on the CPU mode. It is usually programmable as well. IOW,
it's implementation- and system-specific and the default value of the
'round_style' is 'round_toward_zero' for generic 'numeric_limits'
template, but can be 'round_to_nearest' for 'float', as the example on
page 340-341 shows.
V
On Mon, 12 Dec 2005 13:44:36 -0500, Victor Bazarov wrote: Jay Nabonne wrote: On Mon, 12 Dec 2005 12:52:07 -0500, dave wrote:
True. When trying to store a double value in an int variable, the double value is rounded to the nearest interger.
TRUE
AFAIK, it rounds towards zero (truncates). So, FALSE.
It depends on the CPU mode. It is usually programmable as well. IOW, it's implementation- and system-specific and the default value of the 'round_style' is 'round_toward_zero' for generic 'numeric_limits' template, but can be 'round_to_nearest' for 'float', as the example on page 340-341 shows.
That's good to know. Thanks!
Richard wrote: True. The following return statement return the value 10.
Return 10,16;
FALSE
Spelling error aside (return), the return value will be 16.
Quote from the C++ Standard (2003):
Sect. 5.18 P. 1 - "A pair of expressions separated by a comma is
evaluated left-to-right and the value of the left expression is
discarded."
Cheers,
Andre
Jay Nabonne <ja*********@sonicNOSPAM.com> schrieb: Float test(); The statement Cout<<test; Is legal because the function test has no parameters. FALSE
Perfectly *legal* (mis-casing of "cout" ignored). It prints out the address of the function test. It will work even if the function has
So the answer 'FALSE' is right, because it is not legal because of
no parameters, but because of 'missing' parentheses(sp?). True. The following is a legal C++ function definition
Void funcTest(int& u, double& v); { Cout<<u<<" "<<v<<endl; } TRUE
FALSE. The trailing semi-colon on the "funcTest" line results in a syntax error.
Actually, it is the '{' following the ';' which triggers an error.
Up to the ';' it is a forward declaration. True. The word const is used before the array declaration in a function heading to prevent the function from modifying the array.
What is an 'array declaration' in a 'function heading'?
FALSE
TRUE. (What else would the const do?)
Give a hint to the compiler, that the function won't.
BTW: you can cast the 'const' away ...
Markus
On Mon, 12 Dec 2005 23:28:09 +0100, Markus Becker wrote: Jay Nabonne <ja*********@sonicNOSPAM.com> schrieb:
Float test(); The statement Cout<<test; Is legal because the function test has no parameters. FALSE Perfectly *legal* (mis-casing of "cout" ignored). It prints out the address of the function test. It will work even if the function has
So the answer 'FALSE' is right, because it is not legal because of no parameters, but because of 'missing' parentheses(sp?).
The answer "TRUE" is right.
Simplistically, to me "legal" means "a compilable, runnable program". The
program as is will compile and run. It just won't do what I believed the
person creating the question meant it would do (it prints out the address
of the function instead of invoking it). But there's nothing illegal about
it. It's a question of desired effect. Someone could quite easily want to
do the above in a debugging situation.
So, the program is completely LEGAL (regardless of how many params the
function has). But it *may* also be INCORRECT. But that wasn't the
question... True. The following is a legal C++ function definition
Void funcTest(int& u, double& v); { Cout<<u<<" "<<v<<endl; } TRUE
FALSE. The trailing semi-colon on the "funcTest" line results in a syntax error.
Actually, it is the '{' following the ';' which triggers an error. Up to the ';' it is a forward declaration.
You are correct. I guess I should have more clearly said "The trailing
semi-colon on the "funcTest" line results in a *subsequent* syntax error."
Since the question stated this was supposed to be a definition (not a
declaration), I assumed the semi-colon was the erroneous part, not the
block following. True. The word const is used before the array declaration in a function heading to prevent the function from modifying the array. What is an 'array declaration' in a 'function heading'?
e.g.
void PrintData(int const data[], int size)
{
for (int i = 0; i < size; ++i)
{
printf("%d\n", data[i]); // OK
data[i] = 0; // BAD. const object
}
}
FALSE TRUE. (What else would the const do?)
Give a hint to the compiler, that the function won't. BTW: you can cast the 'const' away ...
Thanks. That was a rhetorical question to the previous caller. ;) Markus
Richard wrote: Can any one correct these true and false answer for me? I did not but I don't know if they are all corrected. THanks
I counted 17 right out of 33 -- did you flip a coin?
Jay Nabonne wrote: On Mon, 12 Dec 2005 23:28:09 +0100, Markus Becker wrote:
Jay Nabonne <ja*********@sonicNOSPAM.com> schrieb:
> Float test(); > The statement > Cout<<test; > Is legal because the function test has no parameters. FALSE
Perfectly *legal* (mis-casing of "cout" ignored). It prints out the address of the function test. It will work even if the function has
So the answer 'FALSE' is right, because it is not legal because of no parameters, but because of 'missing' parentheses(sp?).
The answer "TRUE" is right.
Simplistically, to me "legal" means "a compilable, runnable program". The program as is will compile and run.
Right.
But the predefined answer also gave a reason why that should be legal.
And that reason is wrong. Thus the answer to the whole question must be:
False.
--
Karl Heinz Buchegger kb******@gascad.at
On Tue, 13 Dec 2005 10:09:06 +0100, Karl Heinz Buchegger wrote: Jay Nabonne wrote: On Mon, 12 Dec 2005 23:28:09 +0100, Markus Becker wrote:
> Jay Nabonne <ja*********@sonicNOSPAM.com> schrieb: > >>>> Float test(); >>>> The statement >>>> Cout<<test; >>>> Is legal because the function test has no parameters. >>> FALSE >> >> Perfectly *legal* (mis-casing of "cout" ignored). It prints out the >> address of the function test. It will work even if the function has > > So the answer 'FALSE' is right, because it is not legal because of > no parameters, but because of 'missing' parentheses(sp?). >
The answer "TRUE" is right.
Simplistically, to me "legal" means "a compilable, runnable program". The program as is will compile and run.
Right. But the predefined answer also gave a reason why that should be legal. And that reason is wrong. Thus the answer to the whole question must be: False.
Given that, I agree.
As an aside, somehow I doubt the person giving these questions thought
about it to this extent. I hope it wasn't a teacher that came up with
the above "problem".
- Jay
Jay Nabonne wrote: Right. But the predefined answer also gave a reason why that should be legal. And that reason is wrong. Thus the answer to the whole question must be: False.
Given that, I agree.
As an aside, somehow I doubt the person giving these questions thought about it to this extent. I hope it wasn't a teacher that came up with the above "problem".
I bet it was a teacher :-)
--
Karl Heinz Buchegger kb******@gascad.at
On 12/12/05 5:04 PM, in article pa****************************@sonicNOSPAM.com, "Jay Nabonne"
<ja*********@sonicNOSPAM.com> wrote: On Mon, 12 Dec 2005 23:28:09 +0100, Markus Becker wrote:
Jay Nabonne <ja*********@sonicNOSPAM.com> schrieb:
> Float test(); > The statement > Cout<<test; > Is legal because the function test has no parameters. FALSE
Perfectly *legal* (mis-casing of "cout" ignored). It prints out the address of the function test. It will work even if the function has
So the answer 'FALSE' is right, because it is not legal because of no parameters, but because of 'missing' parentheses(sp?).
The answer "TRUE" is right.
Simplistically, to me "legal" means "a compilable, runnable program". The program as is will compile and run. It just won't do what I believed the person creating the question meant it would do (it prints out the address of the function instead of invoking it). But there's nothing illegal about it. It's a question of desired effect. Someone could quite easily want to do the above in a debugging situation.
So, the program is completely LEGAL (regardless of how many params the function has). But it *may* also be INCORRECT. But that wasn't the question...
The answer to the question being asked is "FALSE".
We know that the code is legal, the question tells us that "cout<<test" is
legal.
We are to decide whether the reason that the code is legal is due to the
fact that test() takes no parameters. Since the code would still be legal if
test did take one or more parameters, the number of parameters that test()
accepts could not be the explanation for why the the code compiles. So the
answer is "FALSE".
The actual reason the code is legal is for the reasons already provided
above.
Greg
On Tue, 13 Dec 2005 16:27:29 +0000, Greg Herlihy wrote: The answer to the question being asked is "FALSE".
We know that the code is legal, the question tells us that "cout<<test" is legal.
We are to decide whether the reason that the code is legal is due to the fact that test() takes no parameters. Since the code would still be legal if test did take one or more parameters, the number of parameters that test() accepts could not be the explanation for why the the code compiles. So the answer is "FALSE".
The actual reason the code is legal is for the reasons already provided above.
Greg
Makes perfect sense. Thanks.
Jay Nabonne <ja*********@sonicNOSPAM.com> schrieb: Simplistically, to me "legal" means "a compilable, runnable program". The program as is will compile and run. It just won't do what I believed the person creating the question meant it would do (it prints out the address
That's the problem with programs: They don't do what the programmer
_wanted_ it to do, but it will do what the programmer _told_ it to ;-)
of the function instead of invoking it). But there's nothing illegal about it. It's a question of desired effect. Someone could quite easily want to do the above in a debugging situation.
The question had some hint on _why_ the answer should be FALSE or TRUE
and this has nothing to do with the number of arguments.
You are correct. I guess I should have more clearly said "The trailing semi-colon on the "funcTest" line results in a *subsequent* syntax error."
Since the question stated this was supposed to be a definition (not a declaration), I assumed the semi-colon was the erroneous part, not the block following.
Semantically, it is, but syntactically it is not. We should try to be
exact-to-the-word in this group, shouldn't we? TRUE. (What else would the const do?)
Give a hint to the compiler, that the function won't. BTW: you can cast the 'const' away ...
Thanks. That was a rhetorical question to the previous caller. ;)
*g*
I didn't mean to criticize you, it was meant to make the topic a little
bit clearer to the previous poster just in case he didn't get your
rhetoric. :-)
Markus
Jay Nabonne <ja*********@sonicNOSPAM.com> schrieb: Makes perfect sense. Thanks.
It could be that you did not get my unquoted point because
of the fact that english isn't my native language and at times
my command of it is a little bit shakey.
Especially when it comes to nit-picking. ;-)
Markus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: gsb |
last post by:
Don't know if this is the right place to post this JavaScript issue.
If not, could someone point me in the right direction please.
I am trying to make a "cross browser compliant" floating...
|
by: Andrew Poulos |
last post by:
I've built a javascript driven quiz. Given that client-side scripting is
not secure, is there a way to "obscure" answers so that they are
unavailable to the casual viewer? For example, If I have an...
|
by: softwareengineer2006 |
last post by:
All Interview Questions And Answers
10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP)
I have listed over 10000 interview questions asked
in interview/placement test papers for...
|
by: vv1 |
last post by:
Write a C program for reading in a message string (with no blanks)
and decoding the message. Store the decoded message in another string
called outString. After decoding is complete, print...
|
by: vp1 |
last post by:
Write a C program for reading in a message string (with no blanks)
and decoding the message. Store the decoded message in another string
called outString. After decoding is complete, ...
|
by: Pyenos |
last post by:
#!/usr/bin/python
####################################################
# answers.py --- A simple answer bot
# Copyright (C) 2006 Logan Lee
#
# MESSAGE:
#
# This program is a simple...
|
by: Frank |
last post by:
I've done this a few times.
In a solution I have a project, Say P1, and need another project that will
contain much code that is similar to that of P1.
I hope no one gets hung up on why I...
|
by: javedna |
last post by:
Can PHP help with the following as I have tried in the MYSQL Forums and cant get any help
Thanks
Nabz
----------------------------------------
Hi I am developing a PHP MYSQL questionnaire...
|
by: srinivasarv |
last post by:
Dear Friends,
kindly help me in correcting the following code
This code is for printing the report from the combo box after selection which connects to different reports as selected. I have...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |