Download presentation
Presentation is loading. Please wait.
Published byHadi Yuwono Modified over 5 years ago
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
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= ………………… ) != '\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; arr<arr+5; ………………… ) 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 ; ………………… ){ str[n] = *e; *e = *s; *s = str[n]; } str[n] = '\0';
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.