Question:
Can anybody help me with this programming coursework?
?
2009-06-18 15:21:32 UTC
syntax and logic of the code should be checked using a suitable ‘C’ development environment such as the Borland software This may require additional code to be written (i.e. a test harness)

1. Write ‘C’ code fragments to:

(a) Declare integer variables called pens, pencils and total.

(b) Assign the value 25 to pens and 15 to pencils.

(c) Using an appropriate ‘C’ expression, assign total the contents of pens plus the contents of pencils.



2. Identify a suitable ‘C’ data type for each of the following:

(a) The number of students in a class.

(b) The title of the course on which a student is enrolled.

(c) The average examination mark for a module.

(d) The department in which the student is enrolled (either BE, CIE, CIS, CM or EME).


3. Consider the following ‘C’ program and clearly identify THREE errors that would prevent the program from compiling. (Note that the line numbers are for reference only and are not considered to be part of the program!)

1. #include (stdio.h)

2. void Main (void) {

3. char c;

4. printf("Enter a sentence:\n");

5. scanf("%c", &c);

6. while (c != ".") {

7. printf("%c\n", c);

8. scanf("%c", &c);

9. }

10. printf(".\n");

11. }



4. Define a constant LENGTH holding the value 5. Why is the use of constants beneficial when writing computer programs?






5. Explain how the code fragment below is executed by a computer and hence write down the output produced.

int x;

int y;

for (y=0; y<5; y++) {

for(x=0; x<=y; x++)

printf("%d", x);

printf("\n");

}


6. A mail-order catalogue charges £3.50 for postage and packing on goods up to and including a total value of £10.00. For orders over £10.00 up to and including £20.00, the cost is reduced to £1.50. However, postage and packing is free for orders over £20.00. Write a ‘C’ program that asks a user to enter the total cost of goods on an order and then displays the amount of postage to be added.



7. Rewrite the if statement below using a switch statement. (Note it is not necessary to include the declarations):

enum boatT {DINGY, ROWING, SPEED, YATCH,

RORO, CRUISELINE};

enum boatT boat;

if ((boat==DINGY) || (boat==ROWING))

size=1;

else

if ((boat==SPEED) || (boat==YATCH))

size=2;

else

size=3;



8. Write a ‘C’ function that accepts two integer parameters and returns the smallest of these values. If both parameters hold the same value, simply return that value.



9. Consider the global declarations and definitions below. Write a ‘C’ function that returns the number of integers in the array board that are less than 10. You should assume that values will have been stored in the array elsewhere.

#define SIZE 50

int board[SIZE][SIZE];



Question 10
(a) Define the terms “Bounded Iteration” and “Unbounded Iteration”.


(b) For each of the scenarios below, identify an appropriate iterative control structure provided by the ‘C’ programming language. You are required to explain your answer.

(i) It is required to repeatedly execute a section of code during the period that the value of a certain variable remains larger than 10.

(ii) It is required to obtain the total number of hours of sunshine in January given that the user enters the number of hours of sunshine for each day.

(iii) A user is asked to enter ‘y’ or ‘n’ to indicate ‘yes’ or ‘no’ to a particular question. If the user enters any other character, the program should again ask that the user enter ‘y’ or ‘n’.


(c) Write a ‘C’ program that reads a sequence of integers terminated by the value -999 and outputs their average. Note the termination value of -999 should not be included in the calculation of the average.


(d) Consider the following global definitions for an array of integers:

int myarr[500];

Write a ‘C’ function called initialise that that sets all elements in the array to the integer value passed as a parameter. For example, the statement initialise(5); should result in all 500 array elements holding the value 5.


Question 11
(a) ‘C’ provides two selection control structures, namely an “if” statement and a “switch” statement. Briefly indicate the circumstances under which each should be used.



(b) Write down the output of the following fragment of ‘C’ code. Explain your answer.

i = 3;

j = 4;

if (i >= j)

if (i > j)

printf("Point A\n");

else

printf("Point B\n");

printf("Point C\n”);



(c) A theatre company offers discount to customers who purchase tickets for performances in bulk. The percentage discounts offered are shown in the table below.

Number of Tickets
Percentage Discount

<3
None

3 to 5 (inclusive)
5%

6 to 10 (inclusive)
10%

>10
20%
Four answers:
justme54s
2009-06-18 15:39:42 UTC
Dude your asking people to do your whole coursework for you, if it was one or two questions that you were like stuck on then that would have been okay. Why don't you have a go at it yourself and if you get stuck come back with a question.
?
2016-10-02 15:25:32 UTC
MS is a level beforehand of a PhD like Bachelors is beforehand of an MS. You get a Masters' first (exceptionally much constantly), then a PhD. it extremely is a next degree. I extremely have a Masters yet no longer a PhD. I had to write a paper with 50 annotated references for the Masters. I understand the paper for a PhD is a hundred references. i'm advantageous some courses furnish varieties of learn, like projects, intern study, etc yet that's the quantity of paintings. you're able to do it! somebody informed me while i began out that the time is going by using besides so why no longer positioned the time in for a level. I took 3 years yet, right here it extremely is. decide some time administration and that helps alot.
Rixyla
2009-06-18 17:02:56 UTC
I agree with the other guy, you shouldn't be asking people here to do your freaking coursework for you, jeez

haven't you got classmates to help you? did you not pay attention in class? sorry to sound so mean, but a lot of us busted our arses off studying and spending ages on computers programming little programs so we could understand stuff to get our grades. In my day it was MS-DOS 5, Turbo Pascal 7 and Windows 3.1 and textbooks. No internet in those days.

Ask your tutor or Facebook your friends instead or something.
zimix2004
2009-06-18 15:27:34 UTC
Seems like quite a heavy load of code to deal with;

Sorry if this isn't the right programming language(i deal in C++).



Here's a website that has helped me for awhile:



http://www.cplusplus.com/reference/


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...