473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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

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
"Daniel Antonson" <An********@comcast.net> wrote in message
news:mp********************@comcast.com...
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.



Jul 23 '05 #1
22 1600
Daniel:

Just off the top of my head, without checking any of my answers, here
is what I have to offer (the ????? means I DEFINENTLY do not
know--double check the answers I did give against others,some of those
questions are a bit tricky--hope this helps):
1) d.
2) b.
3) a.
4) d.
5) c.
6) b.
7) b.
8) c.
9) d.
10) a.
11) a.
12) ????????????????
13) a.
14) b.
15) b.
16) a.
17) ????????????
18) a.
19) b.
20) c.
21) a.
22) ??????????
23) b.
24) d.
25) b.

John

"Daniel Antonson" <An********@comcast.net> wrote in message
news:ep********************@comcast.com...
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
"Daniel Antonson" <An********@comcast.net> wrote in message
news:mp********************@comcast.com...
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.


Jul 23 '05 #2

"Daniel Antonson" <An********@comcast.net> wrote in message
news:ep********************@comcast.com...
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


Yeah, I'd agree. This isn't the proper approach.

No amount of hardship justifies us simply giving you the answers to your
homework. Plus, it won't help you, and it won't help anyone else, if you
pass a course simply by having the answers fed to you.

Please, folks, don't give him the answers!

-Howard
Jul 23 '05 #3
Daniel:

After thinking about it a bit, my best guesses on the questions I
didn't answer at first are:
12) d.
17) b.
22) b.

John

"Daniel Antonson" <An********@comcast.net> wrote in message
news:ep********************@comcast.com...
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
"Daniel Antonson" <An********@comcast.net> wrote in message
news:mp********************@comcast.com...
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.


Jul 23 '05 #4
Daniel:

If you use all my answers, at the very least you will get a passing
grade...

John

"Daniel Antonson" <An********@comcast.net> wrote in message
news:ep********************@comcast.com...
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
"Daniel Antonson" <An********@comcast.net> wrote in message
news:mp********************@comcast.com...
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.


Jul 23 '05 #5
Daniel Antonson wrote:
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


I don't have a copy of the C standard handy to check, but I think that
none of these is actually correct, as the program fragment exhibits
undefined behavior.
Jul 23 '05 #6
Alan:

The code obviously prints out the ascii value (55) of the character
'7'.

%d instructs the printf statement to print an integer representation

John

"Alan Johnson" <al****@stanford.dot.nospam_edu> wrote in message
news:da**********@news.Stanford.EDU...
Daniel Antonson wrote:
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


I don't have a copy of the C standard handy to check, but I think
that none of these is actually correct, as the program fragment
exhibits undefined behavior.

Jul 23 '05 #7
John Smith wrote:
Daniel:

If you use all my answers, at the very least you will get a passing
grade...


And he won't have learned a thing. Perhaps you can explain to us what you
think the purpose of a course is?

DW
Jul 23 '05 #8
David:

I obviously do not need to explain anything at all to you, your are
rude and quite egotistical in even suggesting I should. What foreign
country have you been spawned in.

Put simply, "NONE OF YOUR DAMN BUSINESS!"

Besides, that is a very simplistic test, anyone with a text book on c
could get to that speed in hours... just been decades since I was in
college and I am a bit old, rusty and slow :(
--or--
I would have answered more quickly!

John

"David White" <no@email.provided> wrote in message
news:x6********************@nasal.pacific.net.au.. .
John Smith wrote:
Daniel:

If you use all my answers, at the very least you will get a passing
grade...


And he won't have learned a thing. Perhaps you can explain to us
what you
think the purpose of a course is?

DW

Jul 23 '05 #9
John Smith wrote:
Alan:

The code obviously prints out the ascii value (55) of the character
'7'.

%d instructs the printf statement to print an integer representation

John

"Alan Johnson" <al****@stanford.dot.nospam_edu> wrote in message
news:da**********@news.Stanford.EDU...
Daniel Antonson wrote:

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


I don't have a copy of the C standard handy to check, but I think
that none of these is actually correct, as the program fragment
exhibits undefined behavior.



But Ch isn't cast to an int, and since printf() is variadic, there is no
guarantee as to what is actually passed as a parameter. I also do not
have my copy of the Standard available, but I'd be willing to bet it's UB.
Jul 23 '05 #10
John Smith wrote:
[redacted]


Oh, and please don't top post, though since you apparently don't care
about the rules of etiquette for this NG (i.e. answering a blatant
"Do-my-homework" request in full), I doubt you'll care about that either.
Jul 23 '05 #11
Me
> >>>2. What is the effect of the following code?
char Ch;
Ch = '7';
printf("%d\n", Ch);
I don't have a copy of the C standard handy to check, but I think
that none of these is actually correct, as the program fragment
exhibits undefined behavior.


But Ch isn't cast to an int, and since printf() is variadic, there is no
guarantee as to what is actually passed as a parameter. I also do not
have my copy of the Standard available, but I'd be willing to bet it's UB.


Default argument promotions are done to values passed to the ... in
varadic functions so char gets promoted to int (or unsigned int on
weird implementations) here.

Jul 23 '05 #12
Red:

This will work:

char ch = '7';

printf("ch = %ld\n", ch);

not only will it work on an ibm pc, but has worked on any mainframe I
have ran on over the decades...

printf("ch = %d\n", (int)ch);
--or--
printf("ch = %ld\n", (long double)ch);

will also work great...

weather the c standard mentions that the upper bits of a larger type
used in a printf will always be guaranteed to be zero or not, I do not
know, nor care, they have been on every system I have ran... at this
point I would have to seen an error occur to get worried, and see
garbage printed out when an int %d in a printf statement is fed a
char...

.... it would not surprise me at all if the new "c" standard mentions a
type cast is automatically done on the data, as fits the occasion...

John

"red floyd" <no*****@here.dude> wrote in message
news:Zm*******************@newssvr14.news.prodigy. com...
John Smith wrote:
Alan:

The code obviously prints out the ascii value (55) of the character
'7'.

%d instructs the printf statement to print an integer
representation

John

"Alan Johnson" <al****@stanford.dot.nospam_edu> wrote in message
news:da**********@news.Stanford.EDU...
Daniel Antonson wrote:
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

I don't have a copy of the C standard handy to check, but I think
that none of these is actually correct, as the program fragment
exhibits undefined behavior.



But Ch isn't cast to an int, and since printf() is variadic, there
is no guarantee as to what is actually passed as a parameter. I
also do not have my copy of the Standard available, but I'd be
willing to bet it's UB.

Jul 23 '05 #13
Red:

Now here you are quite correct.

The old standards of news groups needs up-dating.

If you need my text formatted in some particular fashion to meet your
standards--write a plug-in for your news reader.

I give you my full permission to view my text in any form which would
please you. You need not ask my permission for any future postings...

If you need help with programming the plug-in, just ask...

John

"red floyd" <no*****@here.dude> wrote in message
news:_n*******************@newssvr14.news.prodigy. com...
John Smith wrote:
[redacted]


Oh, and please don't top post, though since you apparently don't
care about the rules of etiquette for this NG (i.e. answering a
blatant "Do-my-homework" request in full), I doubt you'll care about
that either.

Jul 23 '05 #14
David White wrote:
John Smith wrote:

If you use all my answers, at the very least you will get a passing
grade...
And he won't have learned a thing. Perhaps you can explain to us what you
think the purpose of a course is?


I wouldn't worry too much.. judging by the other clunkers that
"John Smith" has come up with on this thread, the OP would probably
fail the test anyway. For example:

John Smith wrote: printf("ch = %ld\n", (long double)ch);
will also work great...


Jul 23 '05 #15
red floyd wrote:
John Smith wrote:
Alan:
SNIP


But Ch isn't cast to an int, and since printf() is variadic, there is no
guarantee as to what is actually passed as a parameter. I also do not
have my copy of the Standard available, but I'd be willing to bet it's UB.


The code is standard compliant and correct. char is always promoted when
passed as an argument.

I'm a little surprised at all the posts where people seem to want to
guess at the standard rather than actually reading it.

Bill
Jul 23 '05 #16
Bill wrote:
red floyd wrote:
John Smith wrote:

SNIP............

I'm a little surprised at all the posts where people seem to want to
guess at the standard rather than actually reading it.

Bill

Following up my previous posting, the relevant sections in the C++
standard are Section 5.2.2, Paragraph 7, and Section 4.5.

Bill
Jul 23 '05 #17
John Smith wrote:

David:

I obviously do not need to explain anything at all to you, your are
rude and quite egotistical in even suggesting I should. What foreign
country have you been spawned in.

Put simply, "NONE OF YOUR DAMN BUSINESS!"

Besides, that is a very simplistic test


Right. And this is exactly why the OP should be able to answer all of the
questions. Anybody who cannot answer at least most of those questions simply
should not call himself a programmer.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #18
John Smith wrote:

Red:

This will work:

char ch = '7';

printf("ch = %ld\n", ch);
Sorry, you failed the test.

not only will it work on an ibm pc, but has worked on any mainframe I
have ran on over the decades...

printf("ch = %d\n", (int)ch);
That one is ok.
--or--
printf("ch = %ld\n", (long double)ch);

Oh my god!
will also work great...


No, it won't

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #19
Bill wrote:
[redacted] Following up my previous posting, the relevant sections in the C++
standard are Section 5.2.2, Paragraph 7, and Section 4.5.

Bill


Thanks for the chapter&verse. I *said* I had a standard, but was
posting from home. Now I know. Thank you.
Jul 23 '05 #20
John Smith wrote:
[redacted]


*PLONK*

Jul 23 '05 #21
John Smith wrote:
David:

I obviously do not need to explain anything at all to you, your are
rude and quite egotistical in even suggesting I should. What foreign
country have you been spawned in.


LOL. This is the internet - we're all foreigners here :-)

--
Lionel B

Jul 23 '05 #22


John Smith wrote:
Red:

Now here you are quite correct.

The old standards of news groups needs up-dating.

Nah, I prefer this old standard:
*plonk*


Brian

Jul 23 '05 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Cobb | last post by:
Hello- I'm interested in building a graphical timeline for a series of tasks that are stored in a SQL Server 2000 database. The tasks reside within a table. We also have a table to track the...
8
by: Daniel Antonson | last post by:
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...
5
by: krose | last post by:
I am looking for a control that would look like a timeline (12 hours) which would allow the user to click at a particular location on the timeline, then allow characteristics to be associated with...
17
by: jshanman | last post by:
I am working on a timeline API that devevelopers can use to add a dynamic timeline to their sites. Here is a *working* demo of the basic interface. (it works for me anyway on ie6 & firefox 1.5)...
1
by: Doug Laidlaw | last post by:
I am running a genealogy site. I want to implement a graphical timeline running horizontally, with events written at 45 degrees, for example. I can do that with a graphic, but the graphic would...
2
by: monteverest | last post by:
I have a movieclip with 15 frame of animation nested on the main timeline. I want to code a delay on the nested clip so that when the playhead reaches the final frame, the nest clip will stop or...
0
by: nbt725 | last post by:
Dear Sir, Hello ! I have use simile timeline. (http://simile.mit.edu/mail.html). I am new to timeline and would like to do following, please guide me. In my timeline I have created 2 bands one...
1
by: doublestack | last post by:
Hi everyone, I have a xml file that Simile Timeline uses to call events...Some of the events have links in them and I need to have those links open a new window. As it stands now the links replace...
5
by: doublestack | last post by:
Hi everyone, I have a xml file that Simile Timeline uses to call events...Some of the events have links in them and I need to have those links open a new window. As it stands now the links replace...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.