



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Module Code: CSCI E
School: Electrical & Electronic Engineering
Programme Title: Bachelor of Engineering Applied Electronics Design – Year 3 Bachelor of Engineering in Electronic Automation and Robotics – Award Bachelor of Engineering in Communications Systems – Award
Programme Code: EAELD_7_Y EELAR_7_Y ECOSY_7_Y EAELN_7_Y
External Examiner(s): Mr. D. Denieffe, Dr. P. O’Sullivan
Internal Examiner (s): Mr. P. Cogan
Instructions: Answer any^ two questions [each 50 marks]. Maximum available marks is 100. Use appropriate comments and indentation in program code.
Duration: 2 Hours
Sitting: Winter 2007
Requirements for this examination: N/A
Note to Candidates: Please check the Programme Title and the Module Title to ensure that you are attempting the
correct examination paper.
If in doubt please contact an Invigilator.
Q1. (a) With reference to the C language explain what header files are and give
examples of their use. [10 marks]
(b) Explain using appropriate examples what the ‘break’ statement does in the C language. Give examples of how it should be used and where its use should be avoided. [10 marks]
(c) Demonstrate how functions are used in C by writing a program that reads in voltage (V) and resistance (R) and which then passes these values to a
function. The function should calculate power ( R
2 = ) and return the result.
The main program should then display the power. [10 marks]
(d) Explain what each line does in each of the following two programs. [20 marks] (i)#include <stdio.h> void main (void) { long unsigned int a = 5, b = 11, c = 0xa; double d = 2e1; a==b; b-=c++; printf ("%lu\t%lu\t%lu\n",a,b,c); a+= c = 3*(int)d; printf ("%d\t%05.1f\t%d\n",a,d,c); }
(ii)#include <stdio.h> main () { float i[5]={9.0,11.0,13.0,15.0,17.0}; float p = &i[1]; int h; h=(int)i[2]; h<<=1; printf ("%d\t%4.1f\n",h,p); printf("%d\t%4.1f\t%u\t%u\n",--h,*p,p,(p++)); }
Q3. (a) A compiled C program creates and uses four logically distinct regions of memory. Discuss what each of these memory regions is used for. [12 marks]
(b) Write a program that reads in a word and which uses a function to count how many capital letters are in the word. This number should then be returned to the main program which then displays it. [13 marks]
(c) Write a program that reads in a word and which uses a function to test to see if this word is a palindrome. A palindrome is a word that is spelt the same forwards as backwards, e.g. NAVAN is a palindrome. [25 marks]
Q4. (a)^ Using programming examples discuss the use dynamic memory allocation in
C programs. (^) [15 marks] (b) Design a program that interfaces a microcontroller to external hardware as follows. An automated environment monitoring station reads wind speed, wind direction, temperature, atmospheric pressure and rainfall. It transmits this data using an SMS text message in the following format; The four characters $AEM followed by a 4 digit wind speed value (in knots), a comma, three digits from 000 to 359 representing wind direction (e.g.NorthEast is 045,West is 270), a comma, 3 digits representing temperature in Kelvin (Temperature in Celsius=Temperature in Kelvin − 273.15), a comma, a 6 digit pressure value (in pascal) with 2 decimal places, a comma, a 3 digit integer giving the rainfall in mm.
For example the following readings; wind speed of 3 knots in a NorthEast direction, a temperature of 21ºC, atmospheric pressure of 101325.2 pascal and rainfall of 2mm would be encoded as
Note: 1 international knot = 1 nautical mile per hour = 1.852 kilometres per hour Temperature in Celsius=Temperature in Kelvin − 273.
continued overleaf ….
Write a program that will display a menu with the following options
(1) Encode text message (2) Decode text message (3) Quit
If option 1 is selected your program should read in
(a) the wind speed in kilometres per hour,
(b) the wind direction (0 to 359 degrees),
(c) temperature in Celsius
(d) atmospheric pressure in pascal
(e) rainfall in mm.
It should then encode the information (performing conversions where needed)
in the format specified above and write it to a text file whose name is read from the user.
If option 2 is selected your program should read in the name of the text file to
use. It should then decode the information in the file, displaying the
(a) the wind speed in kilometres per hour,
(b) the wind direction as the closest compass point, i.e. 41degrees would be
displayed as NorthEast.
Compass point Heading North 0.00° Northeast 45.00° East 90.00° Southeast 135.00° South 180.00° Southwest 225.00° West 270.00° Northwest 315.00°
(c) temperature in Celsius
(d) atmospheric pressure in pascal
(e) rainfall in mm.
If option 3 is selected your program should quit. [35 marks]
ooooOOOOoooo