Presentation is loading. Please wait.

Presentation is loading. Please wait.

Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC3320 1.

Similar presentations


Presentation on theme: "Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC3320 1."— Presentation transcript:

1 Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC3320 1

2 Xuan Guo Multiple choice Short answers Complete programs Write the output Write a program Bonus question CSC3320 2

3 Xuan Guo identifier integer arithmetic operation scanf(), printf(), convention specifies getchar() function declaration assignment of a pointer, & access to the member of the structure 2-dimensional array initilization String, char array, strlen(), strcmp() open(), lseek(), fork(), pid, orphan process static, directive sqrt() CSC3320 3

4 Xuan Guo double sqrt(double x) Returns the square root of x. size_t strlen(const char *str) Computes the length of the string str up to but not including the terminating null character. char *strcpy(char *dest, const char *src) Copies the string pointed to by src to dest. int strcmp(const char *str1, const char *str2) Compares the string pointed to by str1 to the string pointed to by str2. CSC3320 4

5 Xuan Guo Example 1 Write a C program to count the occurrences of a fixed word in a string. CSC3320 5

6 Xuan Guo Example 2 void main(void) { int i=2,j=3; int p=&i, q=&j ; printf(“*p=%d *q=%d”,*p,*q); q=p; printf(“*p=%d *q=%d”,*p,*q); *p=j; printf(“*p=%d *q=%d”,*p,*q); } CSC3320 6

7 Xuan Guo Example 3 The following recursive function is used to convert a positive integer n to a string a. When converting the integer, the digits are reversed. For example, 483 is converted to string “384”. void convert(char *a, int n) { int i=0; i=n/10; *a=__________; // the last digit of current number if(i!=0) convert(_________,i); // pass the address for next character and value of current number else *(a+1)=’\0’; } void main(void){ char str[10]; convert(str,123); printf(“the converted str is %s\n”, str); } CSC3320 7

8 Xuan Guo Example 4 CSC3320 8

9 Xuan Guo Example 5 int sbs( int x, int y, int *p1, int *p2) { int m; *p1=x*x; *p2=y*y; m=*p1+*p2; return m; } void main(void) { int a=3, b=5, c, d; printf(“%d \n”, sbs(a, b, &c, &d)); printf(“%d %d %d %d\n”, a, b, c, d); } CSC3320 9


Download ppt "Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC3320 1."

Similar presentations


Ads by Google