Question: The question are with reference to the C Programming Language. Q1 In each of the following program segments, find the ALL the error(s) in the
The question are with reference to the C Programming Language.
Q1
In each of the following program segments, find the ALL the error(s) in the program. Where suitable, you can just circle or mark where the error is.
(a) int x[5]; y[5]; char *st2; sPtr[5]; x=y; /* copy y to x sPtr=st2; / / copy string st2 to sPtr printf("New string = %c ; sPtr);
(b) The following code should print whether a given integer is odd or even: switch (value %2 ) { case 0: printf (Even integer ); case 1: printf(Odd integer); break; }
(c) The following code should output the even integers from 2 to 150 (inclusive): counter = 2; do { if (counter % 2 = 0) ; { printf(%d , counter); counter ++; } } while (counter < 150)
(d) /* print j and k until k is no longer less than j int j=100, k=2; while ( 1 ) { printf ("j= %d, k= %d " , j, k); if (j = k) || (k > j) continue; k =- 2; j =+ 2; }
(e)
The following is a function definition for a function to compute the sum and average of numbers in an array of size n. The average (avg) and sum (sum) are to be returned by reference. Find and correct the errors in the function.
void intSumAvg (int a[ ], int n, int avg, int sum) { int k; sum=0; for (k=0; k
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
