In a timeline pinch (Suspense: 25Jul05) pleading for assistance - Q1

  • Thread starter Daniel Antonson
  • Start date
D

Daniel Antonson

Fellow programmers,

As one of you pointed out, I've been taking 3 online courses (2 are done)
and have run into a time crunch. I started these courses in Oct04, but
between work (US Army in DC), caring for my wife (stroke in Dec03 due to
lupus complications) & daughter (4), and preparing for transfer/deployment
(my stepson,- 23, says he'll care for them during my absence). I've had
little time for anything else.

I would greatly appreciate your assistance. Granted, it isn't the proper
approach, but the time
remaining demands urgent solutions.

very respectfully,
Daniel

1. Which of the following usually indicates that there is no more input to
be read by a program?

a. '\n'
b. '\0'
c. END
d. EOF


2. What is the effect of the following code?
char Ch;
Ch = '7';
printf("%d\n", Ch);

a. It will cause an error
b. It will print out the computer's internal code for the character '7'
c. It will print out the character '7'
d. It will print out the character whose internal code is 7


3. What is the effect of the following code?
char Ch;
while ((Ch=getchar() ) != ';')
putchar (Ch);

a. It will read and write characters until something other than a ; is read.
b. It will read characters up to and including the first semicolon, and
write characters up to but not including the first semicolon.
c. It will read and write characters up to but not including the first
semicolon.
d. It will skip characters up to the first semicolon, then write the next
character.


4. It is necessary to use an int instead of a char for processing a
character:

a. whenever a computation is performed on the character.
b. whenever a test for EOF is made.
c. whenever the character is passed as a parameter to a function.
d. It is never necessary to use an int for character processing.


5. What characters are output by the following code:

char Ch='/';
while (Ch != 'd')
{
putchar(Ch);
Ch = getchar();
}

given the following input? abcdefghi

a. abc
b. d
c. /abc
d. /efghi


6. What is the effect of the following code?

char Ch;
while ((Ch = getchar()) != '\n')
putchar(' ');

a. It reads and writes exactly one line with a blank after each character.
b. It reads one line but outputs only blanks.
c. It reads a line and then outputs one blank.
d. It reads and writes one line with all blanks replaced by newlines.


7. In general, when an int is combined with a long in an expression, the
result is:

a. int
b. long
c. double
d. A syntax error


8. Given the following declarations:

int N;
char C;
float X;

what is the type of the expression C+N*X?

a. char
b. int
c. float
d. The expression contains a syntax error


9. Given the following declarations and initialization:

int i = 1;
int x = 2.0;

What is the value and type of the expression i/x?

a. .5 double
b. .5 int
c. 0.0 float
d. 0 int


10. Given the following declarations and initializations:

int n = 8;
int z = 2.0;

What is the value and type of the expression z=n?

a. 8 int
b. 8 float
c. 8 double
d. 8 unsigned


11. Which of the following statements is true?
a. int expressions are always computed exactly; but float expressions can
suffer round-off error
b. float expressions are always computed exactly; but int expressions can
suffer round-off error
c. Both int and float expressions can suffer round-off error
d. Both int and float expressions will always be computed exactly


12. Given the following declarations:

int N;
float X;

what is the type of the expression X%N?

a. int
b. float
c. double
d. can't use float with %


13. Choose the C statement which defines an enumeration type fuzzy
consisting of values false, maybe, and true. Defined so that maybe is
greater in value than false but less than true.

a. enum fuzzy {false, maybe, true};
b. enum fuzzy {true, false, maybe};
c. enum fuzzy {false, maybe, true}
d. enum fuzzy {true, maybe, false};


14. Given the type definition below:

enum color {red, yellow, green, blue};

what is the value of the expression (int) blue?

a. 2
b. 3
c. 4
d. blue


15. Which of the following statements allocates space for a variable of the
defined enum type?

a. enum color {red, yellow, blue} paint;
b. enum color {red, yellow, blue};
c. enum {red, yellow, blue} paint;
d. a and c


Answer questions 16 and 17 given the following values for the int variables
X and Y

X=1100110000110011
Y=0000111100001010


16. What is the binary representation of X<<5?

a. 1000011001100000
b. 1000011001111111
c. 0000110011000000
d. 0000110011111111


17. What is the two's complement of -Y (negative Y)?

a. 0000111100001010
b. 1111000011110101
c. 1111000011110110
d. 1100000000110001


18. If X is an int variable, what do we know about the value of X&X?

a. It is always equal to X.
b. It is always greater than 1.
c. It is always equal to zero.
d. It is always equal to 1.


19. A pointer variable contains:

a. an integer.
b. the address of another variable.
c. any data type.
d. a character string.


20. The term "dereferencing" means:

a. taking the address of another variable.
b. deleting a variable.
c. retrieving the value of a variable given its address.
d. making an assignment to a pointer variable.


21. Which of the statements below is true of the following declaration:

int n=5, *p=&n;

a. p is a pointer initialized to point to n.
b. p is a pointer initialized to the value 5.
c. n and p are both pointer variables.
d. The declaration contains a syntax error


22. Call-by-reference is:

a. not available in C.
b. accomplished by declaring a formal parameter to be a pointer.
c. accomplished be using a de-referenced pointer as a parameter.
d. accomplished by putting an ampersand (&) in the formal parameter.


23. If you want a variable declared inside a function to retain its previous
value when the block is re-entered, what type of storage class should you
use?

a. auto
b. static
c. register
d. extern


24. The address operator & cannot be applied to which of the following?

a. constants
b. expressions
c. variables of class register
d. All of the above


25. Write the output produced by the following code:

int x=5, y=6, *p=&x, *q=&y;
x=*q;
*p = *q + 2;
*q=x;
printf("%d %d %d %d\n", x, y, *p, *q);

a. 8 8 8 8
b. 5 6 5 6
c. 6 8 5 6
d. 6 8 6 8
 
A

Anonymous 7843

As one of you pointed out, I've been taking 3 online courses (2 are done)
and have run into a time crunch. I started these courses in Oct04, but
between work (US Army in DC), caring for my wife (stroke in Dec03 due to
lupus complications) & daughter (4), and preparing for transfer/deployment
(my stepson,- 23, says he'll care for them during my absence). I've had
little time for anything else.

I would greatly appreciate your assistance. Granted, it isn't the proper
approach, but the time
remaining demands urgent solutions.

very respectfully,
Daniel

If you don't have the time to devote to learning, then the respectful
thing to do is drop the course.

The fact that you've essentially requested us to help you cheat
calls into question whether you might cheat us, e.g. by posting a
made-up sob story.
 
M

Me

I would greatly appreciate your assistance. Granted, it isn't the proper
approach, but the time
remaining demands urgent solutions.

I agree, 3 weeks is really urgent for a 25 question multiple choice
homework assignment.
1. Which of the following usually indicates that there is no more input to
be read by a program?

a. '\n'
b. '\0'
c. END
d. EOF
Depends

2. What is the effect of the following code?
char Ch;
Ch = '7';
printf("%d\n", Ch);

a. It will cause an error
b. It will print out the computer's internal code for the character '7'
c. It will print out the character '7'
d. It will print out the character whose internal code is 7

It will print out the contents of the value bits of Ch as a decimal
number to the stdout file stream.
3. What is the effect of the following code?
char Ch;
while ((Ch=getchar() ) != ';')
putchar (Ch);

a. It will read and write characters until something other than a ; is read.
b. It will read characters up to and including the first semicolon, and
write characters up to but not including the first semicolon.
c. It will read and write characters up to but not including the first
semicolon.
d. It will skip characters up to the first semicolon, then write the next
character.

None of the answers handle EOF
4. It is necessary to use an int instead of a char for processing a
character:

a. whenever a computation is performed on the character.
b. whenever a test for EOF is made.
c. whenever the character is passed as a parameter to a function.
d. It is never necessary to use an int for character processing.

In the contexts where it is correct to treat a char as int
5. What characters are output by the following code:

char Ch='/';
while (Ch != 'd')
{
putchar(Ch);
Ch = getchar();
}

given the following input? abcdefghi

a. abc
b. d
c. /abc
d. /efghi

Doesn't handle EOF
6. What is the effect of the following code?

char Ch;
while ((Ch = getchar()) != '\n')
putchar(' ');

a. It reads and writes exactly one line with a blank after each character.
b. It reads one line but outputs only blanks.
c. It reads a line and then outputs one blank.
d. It reads and writes one line with all blanks replaced by newlines.

Doesn't handle EOF
7. In general, when an int is combined with a long in an expression, the
result is:

a. int
b. long
c. double
d. A syntax error

It depends on the expression and what you mean by combined. If you mean
the usual arithmetic conversions, the answer is B.
8. Given the following declarations:

int N;
char C;
float X;

what is the type of the expression C+N*X?

a. char
b. int
c. float
d. The expression contains a syntax error

C, why?
9. Given the following declarations and initialization:

int i = 1;
int x = 2.0;

What is the value and type of the expression i/x?

a. .5 double
b. .5 int
c. 0.0 float
d. 0 int

D, why?
10. Given the following declarations and initializations:

int n = 8;
int z = 2.0;

What is the value and type of the expression z=n?

a. 8 int
b. 8 float
c. 8 double
d. 8 unsigned

A, why?
11. Which of the following statements is true?
a. int expressions are always computed exactly; but float expressions can
suffer round-off error
b. float expressions are always computed exactly; but int expressions can
suffer round-off error
c. Both int and float expressions can suffer round-off error
d. Both int and float expressions will always be computed exactly

Depends if you consider overflow as computed correctly or undefined
behavior as round-off error.
12. Given the following declarations:

int N;
float X;

what is the type of the expression X%N?

a. int
b. float
c. double
d. can't use float with %

This is trival to check with a compiler
13. Choose the C statement which defines an enumeration type fuzzy
consisting of values false, maybe, and true. Defined so that maybe is
greater in value than false but less than true.

a. enum fuzzy {false, maybe, true};
b. enum fuzzy {true, false, maybe};
c. enum fuzzy {false, maybe, true}
d. enum fuzzy {true, maybe, false};

Did you even attend class?
14. Given the type definition below:

enum color {red, yellow, green, blue};

what is the value of the expression (int) blue?

a. 2
b. 3
c. 4
d. blue

Both B and D are correct.
15. Which of the following statements allocates space for a variable of the
defined enum type?

a. enum color {red, yellow, blue} paint;
b. enum color {red, yellow, blue};
c. enum {red, yellow, blue} paint;
d. a and c

D, why?
Answer questions 16 and 17 given the following values for the int variables
X and Y

X=1100110000110011
Y=0000111100001010

I'm assuming this is the value representation in binary where the sign
bit is the MSB.
16. What is the binary representation of X<<5?

a. 1000011001100000
b. 1000011001111111
c. 0000110011000000
d. 0000110011111111
undefined

17. What is the two's complement of -Y (negative Y)?

a. 0000111100001010
b. 1111000011110101
c. 1111000011110110
d. 1100000000110001

How are signed integers stored and how do you want to define the
operation "taking the two's complement of -Y"?
18. If X is an int variable, what do we know about the value of X&X?

a. It is always equal to X.
b. It is always greater than 1.
c. It is always equal to zero.
d. It is always equal to 1.

A, why?
19. A pointer variable contains:

a. an integer.
b. the address of another variable.
c. any data type.
d. a character string.

I don't see an answer that takes into account: the null pointer value,
if the pointer is uninitialized, doesn't point to valid memory, a
pointer of an intermedite cast, etc.
20. The term "dereferencing" means:

a. taking the address of another variable.
b. deleting a variable.
c. retrieving the value of a variable given its address.
d. making an assignment to a pointer variable.
C

21. Which of the statements below is true of the following declaration:

int n=5, *p=&n;

a. p is a pointer initialized to point to n.
b. p is a pointer initialized to the value 5.
c. n and p are both pointer variables.
d. The declaration contains a syntax error

A, why?
22. Call-by-reference is:

a. not available in C.
b. accomplished by declaring a formal parameter to be a pointer.
c. accomplished be using a de-referenced pointer as a parameter.
d. accomplished by putting an ampersand (&) in the formal parameter.

Neither the C++ nor C standards define this term so it can mean
anything you want it to mean. Any thing but answer C (which is complete
nonsense) can be considered correct.
23. If you want a variable declared inside a function to retain its previous
value when the block is re-entered, what type of storage class should you
use?

a. auto
b. static
c. register
d. extern

B, why?
24. The address operator & cannot be applied to which of the following?

a. constants
b. expressions
c. variables of class register
d. All of the above

Depends on the person with the answer sheet. C is correct but they'll
probably say D.
25. Write the output produced by the following code:

int x=5, y=6, *p=&x, *q=&y;
x=*q;
*p = *q + 2;
*q=x;
printf("%d %d %d %d\n", x, y, *p, *q);

a. 8 8 8 8
b. 5 6 5 6
c. 6 8 5 6
d. 6 8 6 8

Do I look like a compiler to you?
 
A

Alan Balmer

Fellow programmers,

As one of you pointed out, I've been taking 3 online courses (2 are done)
and have run into a time crunch. I started these courses in Oct04, but
between work (US Army in DC), caring for my wife (stroke in Dec03 due to
lupus complications) & daughter (4), and preparing for transfer/deployment
(my stepson,- 23, says he'll care for them during my absence). I've had
little time for anything else.

I would greatly appreciate your assistance. Granted, it isn't the proper
approach, but the time
remaining demands urgent solutions.

The best solution is to pick up the book. The questions you've posted
are elementary and should require only minimum study to answer.
Answering them for you would be a disservice.

If you truly don't have time now, admit it and reschedule.
 
K

Keith Thompson

Daniel Antonson said:
Fellow programmers,

As one of you pointed out, I've been taking 3 online courses (2 are done)
and have run into a time crunch. I started these courses in Oct04, but
between work (US Army in DC), caring for my wife (stroke in Dec03 due to
lupus complications) & daughter (4), and preparing for transfer/deployment
(my stepson,- 23, says he'll care for them during my absence). I've had
little time for anything else.

I would greatly appreciate your assistance. Granted, it isn't the proper
approach, but the time
remaining demands urgent solutions.

very respectfully,
Daniel
[questions snipped]

Assuming your story is accurate, you have my sympathy. That does not,
however, imply a willingness to help you cheat.

Why are you taking these online courses? What are the consequences if
you fail the third one? What possible benefit could there be in your
passing this course without actually understanding the material? And
what harm could result, either to you or to others (such as any
potential employers or co-workers) if you pass the course by cheating?

I've looked through the questions, and I believe that most of the
regulars here could answer all of them off the top of their heads
(though there were several serious ambiguities). If you can't, then I
suggest that failing grade you're about to receive is appropriate.
 
S

Suman

Daniel said:
13. Choose the C statement which defines an enumeration type fuzzy
consisting of values false, maybe, and true. Defined so that maybe is
greater in value than false but less than true.

a. enum fuzzy {false, maybe, true};
b. enum fuzzy {true, false, maybe};
c. enum fuzzy {false, maybe, true}
d. enum fuzzy {true, maybe, false};

Why did they have to give 4 choices? Because that was a requirement?
a and c looks identical, so either you've messed it up while posting,
or you're wasting your time taking a worthless course.
 
M

Martin Ambuhl

Suman said:
Daniel Antonson wrote:




Why did they have to give 4 choices? Because that was a requirement?
a and c looks identical, so either you've messed it up while posting,
or you're wasting your time taking a worthless course.


Look again. Choice c is missing something.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top