Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC215 Homework Homework 05 Due date: Oct 21, 2016.

Similar presentations


Presentation on theme: "CSC215 Homework Homework 05 Due date: Oct 21, 2016."— Presentation transcript:

1 CSC215 Homework Homework 05 Due date: Oct 21, 2016

2 Question 1 : Evaluate each of the following expressions
int x[4] = {12, 20, 39, 43}, *y; y = x; Assume each expression is evaluated after the previous one (take all previous ones in consideration) *y + 1 *(y + 1) y += 2; *y *y = 38 *y - 1 *y++ *y y[0] x[2] > y[0] y - x 13 1 20 1 39 1 38 1 37 1 43 1 0 1 3 1

3 Question 2 : Fill in the blank so the code does what is desired.
1) A code that prints all characters of the string. char ch, *str = "Hello World"; while((ch= *str++ ) != '\0') printf("%c", ch); 2) A code that prints the elements at the even indices. int *p, arr[] = {10,33,15,22,14}; for (p=arr; p<arr+5; p += 2 ) /* corrected */ printf("%d ", *p); 3) A code that reverses a string: char n=0, *s, *e, str[] = "siht hsinif ot ekil I"; while (str[++n]); for(s=str, e=str+n-1; e>s ; e--,s++ ){ str[n] = *e; *e = *s; *s = str[n]; } str[n] = '\0';


Download ppt "CSC215 Homework Homework 05 Due date: Oct 21, 2016."

Similar presentations


Ads by Google