December 1998
CA208: 'C' PROGRAMMING

QUESTION 4

Total Marks: 20 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 4

 

(a) What is the effect of adding the keyword static to a local variable in a procedure?

 

[2]
(b) Describe the difference between call-by-reference and call-by-value parameter passing in C.

 

[4]
(c) Find the eight syntax errors in the following fragment of code:

include <stdio.h>

void func(int x[], int y)

main() {
   int a(5), b, i;

   for (i=0;i<5,i++) a[i] = 2*1;

   b==16;
   for(i=0;i<5;i++) printf("%d\n,a[i]);
   return;
}

void func(int x[], int y);
{
   integer i;
   for(i=0;i<5;i++) {
      x[i]+=2;
   y+=2;

}

 

[8]
(d) Write a function that prompts the user to enter a number in the range 0-4. If the number entered is outside the required range, a prompt for user input should be repeated; otherwise the function returns the integer selected by the user.

 

[6]